I have a 2d arrays button [5,5] all blue color...how to randomly generate 5 red button in the array...?
int Rows = 5;
int Cols = 5;
Button[] buttons = new Button[Rows * Cols];
int index = 0;
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
Button b = new Button();
b.Size = new Size(40, 55);
b.Location = new Point(55 + j * 45, 55 + i * 55);
b.BackColor = Color.Blue;
buttons[index++] = b;
}
}
panel1.Controls.AddRange(buttons);