2
Good evening, my teacher of programming language asked us to make a program, that when calling the event Form1_load generate 200 buttons, until then I did, but I wanted to implement a function that click on a button, regardless of which it changed color. But without having to add the 200 buttons in the code, follow the code:
public partial class Form1 : Form
{
Button[] btn = new Button[200];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
char letra = 'A';
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 20; j++)
{
btn[i] = new Button();
btn[i].Name = letra.ToString() + j + 1;
btn[i].Text = letra.ToString() + (j + 1);
btn[i].BackColor = Color.Green;
btn[i].Location = new Point(90 * (i + 1), 30 * (j + 1));
Controls.Add(btn[i]);
}
letra++;
}
}
}
Thanks bro, you helped a lot !
– FioritoN