Jul 7, 2011
How Do I count all CheckBoxes checked those are placed in groups boxes in form
private void ChkStatus()
{
Chkcount = 0;
foreach (Control ctrl in this.Controls)
{
if (ctrl is GroupBox)
{
foreach (Control ctrl1 in ctrl.Controls)
{
if (ctrl1 is CheckBox)
{
//cast the ctrl to a checkbox and disable it
if (((CheckBox)ctrl1).Checked == true)
{
Chkcount++;
}
// ((CheckBox)ctrl).Checked = true;
}
}
}
}
MessageBox.Show(Chkcount.ToString());
}
this will display the total count of the check boxes checked in form including group boxes check boxes also
Labels:
c#.net,
check boxes,
groupbox
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment