Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a groupbox with 10 checkboxes in it.

I want to select multiple checkboxes at a time.

I don't know how.

Please help me.
Posted
Updated 20-Apr-11 21:46pm
v2
Comments
Toniyo Jackson 21-Apr-11 3:22am    
At a time means? In one click do you want to select all 10?
Saptur 21-Apr-11 3:27am    
no no.. i select Separately..
Toniyo Jackson 21-Apr-11 3:29am    
It should work by default.
Dalek Dave 21-Apr-11 3:46am    
Edited for Grammar, Syntax, Clarity and Readability.

MIDL
foreach (Control c in this.groupBox1.Controls)
{
    if (c.GetType() == typeof(CheckBox))
    {
        ((CheckBox)c).Checked = true;
    }
}
 
Share this answer
 
Comments
Saptur 21-Apr-11 3:24am    
thanks.. but i've some doubt..
where i load...
Sergey Alexandrovich Kryukov 21-Apr-11 4:29am    
Where you want. Think logically. Can be even before UI is shown (form constructor), one some event...
--SA
Dalek Dave 21-Apr-11 3:47am    
Sounds Reasonable!
Sergey Alexandrovich Kryukov 21-Apr-11 4:28am    
Agree, a 5.
--SA
Uday Kumar B R 21-Apr-11 5:37am    
Nice Answer :-)
You can do this way also,

foreach (CheckBox c in groupBox1.Controls)
      {
        if (c.Checked == false)
           c.Checked = true;
      }


Write above code in Page Load and check it out .....

Once you get your checkbox then you can write your logic inside foreach loop.
 
Share this answer
 
Comments
Dalek Dave 21-Apr-11 3:47am    
Good Answer.

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