U Form1.Designer.cs :
System.Windows.Forms.Button[,] pole = new System.Windows.Forms.Button[15, 15];
int indx = 2;
int x = 12, y = 37;
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 15; j++)
{
pole[i, j] = new System.Windows.Forms.Button();
pole[i, j].Name = "btn" + i.ToString() + j.ToString();
pole[i, j].Size = new System.Drawing.Size(20, 20);
pole[i, j].Location = new System.Drawing.Point(x, y);
pole[i, j].TabIndex = indx;
pole[i, j].BackColor = System.Drawing.Color.White;
pole[i, j].FlatStyle = System.Windows.Forms.FlatStyle.Flat;
pole[i, j].Text = "";
pole[i, j].UseVisualStyleBackColor = false;
x += 19;
indx++;
Controls.Add(pole[i, j]);
pole[i, j].MouseDown += new System.Windows.Forms.MouseEventHandler(this.HraciP ole_MouseDown);
}
}
u Form1.cs
private void HraciPole_MouseDown(object sender, MouseEventArgs e)
{
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 15; j++)
{
?????? pole[i, j];
}
}
}