An array creation request initializes elements only null. You need to create them individually.
TextBox[] txtTeamNames = new TextBox[teams];
for (int i = 0; i < txtTeamNames.Length; i++) {
var txt = new TextBox();
txtTeamNames[i] = txt;
txt.Name = name;
txt.Text = name;
txt.Location = new Point(172, 32 + (i * 28));
txt.Visible = true;
}
Note. As pointed out by several people, for this code to make sense, you need to add each TextBoxto the parentControl
source
share