I have about 20 checkboxes on the form. How can I name them to use them later in a for loop for example? A thing such an array checkBox[i].
Regards
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I am assuming that the controls are being created as part of
InitializeComponent(), i.e. it’s done by designer code.The straightforward approach would be to do this after
InitializeComponentis called:A better way would be to use LINQ to put all checkboxes in an array:
However, this will not work recursively and you may have to filter some checkboxes out of the collection if you don’t want all of them to be in the array.