Counting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have a form with 6 checkboxes. What is the best way to count how many
checkboxes have been checked?

Thanks
 
Hi Jez,

You could keep the CheckBoxes in a CheckBox array

int count = 0;
foreach(CheckBox cb in CBArray)
if(cb.Checked)
count++;

Not sure why you would want to know how may CheckBoxes are checked instead
of which ones.
 
It would also possible to use a CheckListBox where you could use
clb.CheckedItems.Count
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top