Pls i need help wit my windows form...i hav 25 buttons wen any of d buttons is clicked nd it all 25 buttons turns red dats d end...this is my question..... How do I randomly assign the
Content of the buttons so that
the correct option 4 all button 2 turn red isn't in the
same button all the time?

Recommended Answers

I'm not sure I understand what you need but if you want to randomly alter one of the buttons in anyway then you first need to randomly select which button to alter.
The Random type can help you there:

Random rand = new Random();
int r = …
Jump to Post

All 2 Replies

I'm not sure I understand what you need but if you want to randomly alter one of the buttons in anyway then you first need to randomly select which button to alter.
The Random type can help you there:

Random rand = new Random();
int r = rand.Next(25);

R now holds a number between 0 and 25 (exclusive) which can relate to the button in question. Then you can use a switch statement to select the button based on r. Is that what you are after?

Hi..
Sorry... I can't get what is ur problem..
Can u explain properperly or put the code snippet here...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.