matthew king

matthew king

  • NA
  • 52
  • 0

Select a random number of textboxes

Apr 3 2011 6:34 PM
 

Sir/Ma'am

 

I have a groupbox that contains several textboxes.  I'm trying to select a random number of said textboxes and change their backcolor to green.  I was able to determine how to iterate through the entire groupbox to change the backcolor of all the textboxes (below), but now I would like to learn how to just change a random number of textboxes backcolor. Specifically, can I change some (i.e. random) of the textboxes backcolor within a specific groupbox? 

  As always, I appreciate your assistance with my learning endeavors…

 

 

  private void button5_Click(object sender, EventArgs e)

        {

            groupBox46.BackColor = Color.White;

            foreach (Control Text in groupBox46.Controls)

 

            {                                               

                Text.BackColor = Color.Green;

                   

            }

        }

    }

}


Answers (5)