8 Kasım 2014 Cumartesi

Counting the number of checked checkboxes in a TabControl

If you have multiple tabs in a tab control and you want to know the total number of checked checkboxes in this tab the following lines will be helpful:

int number = 0;
foreach (TabPage tp in tabControl1.Controls)
     foreach (Control c in tp.Controls)
          if (c is CheckBox)
               if (((CheckBox)c).Checked)
                    number++;

MessageBox.Show("" + number);

You may change the code easily to get the number of non-null textboxes and so on..

Hiç yorum yok: