How to get access from a class to dynamically created form elements (in my case, textBox)?
This is how I create the elements:
for (int i = 1; i <= Convert.ToInt32(input); i++) { panel1.Controls.Add(new TextBox() { Name = i.ToString(), Location = new Point(54, yTextBox_n = yTextBox_n + 35), Font = new Font("Times New Roman", 14.25f) }); panel1.Controls.Add(new Label() { Name = i.ToString(), Location = new Point(8, yLabel_n = yLabel_n + 35), Text = "n" + i, Font = new Font("Times New Roman", 14.25f, FontStyle.Italic) }); } I have an algorithm. I enter the necessary data from the form and these dynamically generated elements are displayed. then I enter the data in them and I need to pass this data to the class algorithm how to pass them?
Here is a class. It is not completed at all. It should receive dynamically created elements.
class Class_Algorithm { int[,] Matrix; int L; int N; public Class_Algorithm(int[,] matrix, int l, int n) { Matrix = matrix; L = l; N = n; } public void Algorithm() { int k = 1; int q = 1; for (int d = 0; d < L; d++) { int m = 1; int z = 1; int[] r = new int[N]; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { r[i] += Matrix[i, j]; } } } } }
for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++)- Igor