Click here to Skip to main content
Rate this: bad
good
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 6:28am
pucx1.2K
Comments
Wes Aday at 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
good
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.
  Permalink  
Comments
pucx at 21-Sep-12 11:34am
   
foreach?could you give a example?
Andrewpeter at 21-Sep-12 11:52am
   
You should search it, when you understand the usage of it you will solve yourself. Thanks.
Marcus Kramer at 21-Sep-12 12:06pm
   
foreach( Control ctl in Controls )
{
if( ctl is CheckBox )
{
// Do your thing...
}
}
pucx at 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
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,142
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2014
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