我试图在Form中动态生成TextBoxes矩阵。在行中 textbox [i] [j] .Size = new Size(w,h); 我收到错误" NullReferenceException"。
TextBox[][] textbox = new TextBox[100][];
int x_point = 70;
int y_point = 70;
int h = 30;
int w = 40;
for (int i = 0; i < number_columns; i++)
{
for (int j = 0; j < number_columns; j++)
{
textbox[i][j] = new TextBox();
textbox[i][j].Size = new Size(h, w); // Here I get the error
textbox[i][j].Location = new Point(x_point, y_point);
y_point = y_point + 40;
this.Controls.Add(textbox[i][j]);
}
y_point = 70;
x_point =x_point + 30;
}