Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Select all items in CheckedListBox with an itam in a CheckedListBox ...

How to Select all items in CheckedListBox with an itam in a CheckedListBox ...

Scheduled Pinned Locked Moved C#
tutorialquestion
12 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IamHuM
    wrote on last edited by
    #1

    Hi... How i can select all items in a CheckedListBox on selction of a first CheckedListBox item...? Items in CheckedListBox are as follows- 'Selct All' First Item Second Item Third Item So on click of 1st CheckedListBox item(SelectAll), i want to select all items...How i can do this...? Thanks in adavnce, Vinay

    C 1 Reply Last reply
    0
    • I IamHuM

      Hi... How i can select all items in a CheckedListBox on selction of a first CheckedListBox item...? Items in CheckedListBox are as follows- 'Selct All' First Item Second Item Third Item So on click of 1st CheckedListBox item(SelectAll), i want to select all items...How i can do this...? Thanks in adavnce, Vinay

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      This is bad UI.  You can make it work, but select all should be a button, not one of the items in the list.

      Christian Graus - C++ MVP

      Steve EcholsS 1 Reply Last reply
      0
      • C Christian Graus

        This is bad UI.  You can make it work, but select all should be a button, not one of the items in the list.

        Christian Graus - C++ MVP

        Steve EcholsS Offline
        Steve EcholsS Offline
        Steve Echols
        wrote on last edited by
        #3

        Christian Graus wrote:

        This is bad UI.

        Not sure I agree with that. If you have a huge field of checkboxes, say to determine which fields to search on, one of the options could be All, which would select all of the checkboxes for you. I've seen this done out in the wild, and it seems to make sense. Not saying there's not a better way, just saying I don't think it's a bad UI. [edit]Ahh, it's a list box. Should have read that a little closer. I agree with Christian, use a button.[/edit]


        - S 50 cups of coffee and you know it's on!

        • S
          50 cups of coffee and you know it's on!
          Code, follow, or get out of the way.
        I C 2 Replies Last reply
        0
        • Steve EcholsS Steve Echols

          Christian Graus wrote:

          This is bad UI.

          Not sure I agree with that. If you have a huge field of checkboxes, say to determine which fields to search on, one of the options could be All, which would select all of the checkboxes for you. I've seen this done out in the wild, and it seems to make sense. Not saying there's not a better way, just saying I don't think it's a bad UI. [edit]Ahh, it's a list box. Should have read that a little closer. I agree with Christian, use a button.[/edit]


          - S 50 cups of coffee and you know it's on!

          I Offline
          I Offline
          IamHuM
          wrote on last edited by
          #4

          I have to make this type of application.... since that is the requirement...so can u tell me ... How i can do this...? Regards, Vinay

          C 1 Reply Last reply
          0
          • Steve EcholsS Steve Echols

            Christian Graus wrote:

            This is bad UI.

            Not sure I agree with that. If you have a huge field of checkboxes, say to determine which fields to search on, one of the options could be All, which would select all of the checkboxes for you. I've seen this done out in the wild, and it seems to make sense. Not saying there's not a better way, just saying I don't think it's a bad UI. [edit]Ahh, it's a list box. Should have read that a little closer. I agree with Christian, use a button.[/edit]


            - S 50 cups of coffee and you know it's on!

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            It doesn't matter what it is, having a check box that says 'select all' makes no sense, it should be a seperate control to the type of control that is being selected ( and probably a button )

            Christian Graus - C++ MVP

            Steve EcholsS 1 Reply Last reply
            0
            • I IamHuM

              I have to make this type of application.... since that is the requirement...so can u tell me ... How i can do this...? Regards, Vinay

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              You absolutely must have a list of checkbox items, and the first item must say 'select all' ? A button is a better choice . But, if you must make a god awful UI, just handle the event for an item to be checked, check if it's the 'check all' item, and if it is, check them all.

              Christian Graus - C++ MVP

              I 1 Reply Last reply
              0
              • C Christian Graus

                It doesn't matter what it is, having a check box that says 'select all' makes no sense, it should be a seperate control to the type of control that is being selected ( and probably a button )

                Christian Graus - C++ MVP

                Steve EcholsS Offline
                Steve EcholsS Offline
                Steve Echols
                wrote on last edited by
                #7

                All [ ] Author [ ] Text [ ] Date [ ] Etc. Granted you could write the same thing with radio buttons or something, like: ( ) All ( ) Selected [ ] Author [ ] Text [ ] Date [ ] Etc. But I'd say the first one makes equally as much sense to most users, especially when it selects all the other check boxes. It's just a shortcut, in either case.


                - S 50 cups of coffee and you know it's on!

                • S
                  50 cups of coffee and you know it's on!
                  Code, follow, or get out of the way.
                1 Reply Last reply
                0
                • C Christian Graus

                  You absolutely must have a list of checkbox items, and the first item must say 'select all' ? A button is a better choice . But, if you must make a god awful UI, just handle the event for an item to be checked, check if it's the 'check all' item, and if it is, check them all.

                  Christian Graus - C++ MVP

                  I Offline
                  I Offline
                  IamHuM
                  wrote on last edited by
                  #8

                  Ok...Can u tell me if i give a single CheckBox(say 'Selct All') outside this CheckBoxList then How i can select all ites in CheckBoxList on selction that CheckBox(Selct All). Thanks for all your replies, Vinay

                  C 1 Reply Last reply
                  0
                  • I IamHuM

                    Ok...Can u tell me if i give a single CheckBox(say 'Selct All') outside this CheckBoxList then How i can select all ites in CheckBoxList on selction that CheckBox(Selct All). Thanks for all your replies, Vinay

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    If there's no CheckAll method on the checkboxlist, use foreach on the items collection to check them all.

                    Christian Graus - C++ MVP

                    I 1 Reply Last reply
                    0
                    • C Christian Graus

                      If there's no CheckAll method on the checkboxlist, use foreach on the items collection to check them all.

                      Christian Graus - C++ MVP

                      I Offline
                      I Offline
                      IamHuM
                      wrote on last edited by
                      #10

                      Hi.. Actually i dont know number of items are there in that CheckBoxList so can you tell me how i can use foreach loop for my CheckBoxList. How i'll get collection of items in that CheckBoxList. Regards, Vinay

                      C S 2 Replies Last reply
                      0
                      • I IamHuM

                        Hi.. Actually i dont know number of items are there in that CheckBoxList so can you tell me how i can use foreach loop for my CheckBoxList. How i'll get collection of items in that CheckBoxList. Regards, Vinay

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #11

                        Do you not know how for each works ? foreach(CheckBoxListITem item in myBox.Items) {    item.Checked = true; } I am sure that's not the type of the items, but that's how it looks.

                        Christian Graus - C++ MVP

                        1 Reply Last reply
                        0
                        • I IamHuM

                          Hi.. Actually i dont know number of items are there in that CheckBoxList so can you tell me how i can use foreach loop for my CheckBoxList. How i'll get collection of items in that CheckBoxList. Regards, Vinay

                          S Offline
                          S Offline
                          Shajeel
                          wrote on last edited by
                          #12

                          you can you this too for (int i = 0; i < this.checkedListBox1.Items.Count; i++) { this.checkedListBox1.SetItemChecked(i, true); }

                          Regards Shajeel

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups