Counting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jez123456

    Counting

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

    Thanks
  • Morten Wennevik

    #2
    Re: Counting

    Hi Jez,

    You could keep the CheckBoxes in a CheckBox array

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

    Not sure why you would want to know how may CheckBoxes are checked instead
    of which ones.


    On Wed, 16 Mar 2005 07:11:07 -0800, jez123456
    <jez123456@disc ussions.microso ft.com> wrote:
    [color=blue]
    > Hi, I have a form with 6 checkboxes. What is the best way to count how
    > many
    > checkboxes have been checked?
    >
    > Thanks[/color]



    --
    Happy Coding!
    Morten Wennevik [C# MVP]

    Comment

    • cody

      #3
      Re: Counting

      It would also possible to use a CheckListBox where you could use
      clb.CheckedItem s.Count

      "jez123456" <jez123456@disc ussions.microso ft.com> schrieb im Newsbeitrag
      news:2FC5FA4F-BF28-4D97-9840-0B5621BFC3DC@mi crosoft.com...[color=blue]
      > Hi, I have a form with 6 checkboxes. What is the best way to count how[/color]
      many[color=blue]
      > checkboxes have been checked?
      >
      > Thanks[/color]


      Comment

      Working...