0
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 function Random
:
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 background his?
myButton(????).Background = Brushes.Red;
I know I could do one by one:
if (numero == 1)
{
BTN_1.Background = Brushes.Red;
}
if (numero == 2)
{
BTN_2.Background = Brushes.Red;
}
But it wouldn’t be right.
I found the answer... @bigown. Should I answer my own question? I don’t know if that’s correct. Thank you
– Ayo
@Ayo yes, please.
– Maniero