i want to dynamically update textbox via button. I've created this for loop:
public void add_players_Click(object sender, EventArgs e)
{
if (enter_name_space.Text == "")
{
messagebox_1 hide = new messagebox_1();
hide.Show();
}
else
{
for (int i = 0; i < 2;)
{
TextBox textBox = new TextBox();
textBox.Text = "Hi";
textBox.Name = "textBox" + i.ToString();
Form1.Controls.Add(enter_name_space);
textBox.Location = new Point(0, 0);
}
}
}
but then error "CS0120: An object reference is required for the nonstatic field, method, or property" occurs on "Form1.Controls". Why is that? How do I fix it?