Jul 7, 2011
Loop through checking Check boxes count
private void button3_Click(object sender, EventArgs e)
{
Form1 frm = new Form1();
int i = 0;
foreach (Control ctrl in this.Controls)
{
if (ctrl is CheckBox)
{
//cast the ctrl to a checkbox and disable it
if (((CheckBox)ctrl).Checked == true)
{
i++;
}
}
}
MessageBox.Show(i.ToString());
}
see the output below
Labels:
c#.net,
check boxes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment