I have a screen with 25 buttons and would like to interact with the buttons through the code.
For example, a number is generated using the Random
function:
Random rdn = new Random();
numero = rdn.Next(0,25);
Let's say the result was 20. How do I call this button that has the tag 20 and then change the color of the background it?
myButton(????).Background = Brushes.Red;
I know I could do it one by one:
if (numero == 1)
{
BTN_1.Background = Brushes.Red;
}
if (numero == 2)
{
BTN_2.Background = Brushes.Red;
}
But it would not be right.