Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
[no name] 21-Sep-12 11:32am    
Yes you could use if-else. An easier way would be to use a for or foreach.

1 solution

You can use a "foreach" loop to handle them, please search how to use "foreach" loop? Good luck.
 
Share this answer
 
Comments
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.
fjdiewornncalwe 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900