i currently have a form which i dynamically created a 2D array of textboxes, buttons etc. i just found out my other parts of the program cannot access to the textboxes i created? is there a way i can do it?
my codes goes something like:
public Form1()
{
int column = 4;
System.Windows.Forms.TextBox[,] textbox = new System.Windows.Forms.TextBox[column, row];
for (int i = 0; i < column; i++)
{
for (int j = 0; j < row; j++)
{
textbox[i, j] = new System.Windows.Forms.TextBox();
textbox[i, j].Size = new Size(80, 20);
textbox[i, j].Name = "textbox_" + i + "_" + j;
textbox[i, j].Location = new System.Drawing.Point((i * 80) + 20, (j * 20) + 30);
textbox[i, j].Visible = true;
Controls.Add(textbox[i, j]);
}
}
/////fill the textboxes with data//////
}
i cannot access the textbox outside the method, how can i do it? can you provide some working coded? i am still relatively new to c#, thank you very much