Im coding in a windowsformapplication, c# This is what i have done so far
List<Button> list = new List<Button>();
private void Form1_Load(object sender, EventArgs e)
{
for (int j = 0; j <= 13; j++)
{
for (int i = 0; i <= 13; i++)
{
Button ruta = new Button();
ruta.Location = new Point(0+ (i * 50), 0 + (j * 50));
ruta.Size = new Size(50, 50);
ruta.AutoSize = false;
ruta.Text = "";
ruta.TabStop = false;
list.Add(ruta);
this.Controls.Add(ruta);
}
}
}
What I now want is to be able to click on of these buttons and then change the text of a textbox to the index of the pressed button, I'm a real noob when it comes to C# so I have no idea what im doing atm. What i thought about was something like
private void ruta_click(object sender, EventArgs e)
{
txtBox.text = list.SelectedItemIndex();
}
which obviously wont work since SelectedItemIndex() isnt a real method but just an example.