Click here to Skip to main content
13,509,265 members
Rate this:
Please Sign up or sign in to vote.
C# how to deal with more than one checkbox controls in the winform gui?
I use C# to develop a form and more than 10 checkbox controls above,what method can I used to be able to handle the 10 checkbox controls selected?
select any number of the 10 checkbox controls,there are A1010 situations,etc. 1 * 2 * 3 * ... * 8 * 9 * 10 so a variety of situations?I can not use the if-else to judge it? ? Seek expert to be able to handle a similar situation a good solution, thank you.
Posted 21-Sep-12 5:28am
Wes Aday 21-Sep-12 11:32am
Yes you could use if-else. An easier way would be to use a for or foreach.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can use a "foreach" loop to handle them, please search how to use "foreach" loop? Good luck.
pucx 21-Sep-12 11:34am
foreach?could you give a example?
Andrewpeter 21-Sep-12 11:52am
You should search it, when you understand the usage of it you will solve yourself. Thanks.
Marcus Kramer 21-Sep-12 12:06pm
foreach( Control ctl in Controls )
if( ctl is CheckBox )
// Do your thing...
pucx 21-Sep-12 13:16pm
but when I get the checked boxs,how can I match data by use these Rule,and get the correct data?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180417.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100