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. Implement CheckBoxes in Listbox?

Implement CheckBoxes in Listbox?

Scheduled Pinned Locked Moved C#
questionwinforms
4 Posts 2 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.
  • M Offline
    M Offline
    MudkiSekhon
    wrote on last edited by
    #1

    Hi friends, Plz suggest me how can i implement checkboxes in listbox in Windows forms application. I want to use checkboxes to select items from the listbox. If possible, plz send me the code..... Thanks, Sandeep +919891027854

    P 1 Reply Last reply
    0
    • M MudkiSekhon

      Hi friends, Plz suggest me how can i implement checkboxes in listbox in Windows forms application. I want to use checkboxes to select items from the listbox. If possible, plz send me the code..... Thanks, Sandeep +919891027854

      P Offline
      P Offline
      Polis Pilavas
      wrote on last edited by
      #2

      Look for a Windows forms' control called CheckedListBox in your toolbox instead Regards, Polis Can you practice what you teach?

      M 1 Reply Last reply
      0
      • P Polis Pilavas

        Look for a Windows forms' control called CheckedListBox in your toolbox instead Regards, Polis Can you practice what you teach?

        M Offline
        M Offline
        MudkiSekhon
        wrote on last edited by
        #3

        Thanks for ur reply. Have u any sample code in which u catch the checkboxes that are selected from the CheckedListBox? I want to select multiple values from tha CheckedListBox.... Regards, Sandeep +919891027854

        P 1 Reply Last reply
        0
        • M MudkiSekhon

          Thanks for ur reply. Have u any sample code in which u catch the checkboxes that are selected from the CheckedListBox? I want to select multiple values from tha CheckedListBox.... Regards, Sandeep +919891027854

          P Offline
          P Offline
          Polis Pilavas
          wrote on last edited by
          #4

          Yes, take a look below at the following self-explanatory code chunk. First I add three items into the checkedListBox, and then I get the text of the selected ones by looping through each one of them:

          string checkedItems = "";

          // Add a few items into the checkedListBox control
          this.checkedListBox1.Items.Add("Item 1", CheckState.Checked);
          this.checkedListBox1.Items.Add("Item 2", CheckState.Indeterminate);
          this.checkedListBox1.Items.Add("Item 3", CheckState.Unchecked);

          // Retrieve the selected items in a string
          for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
          {
          if (this.checkedListBox1.GetItemChecked(i))
          checkedItems += this.checkedListBox1.Items[i].ToString() + "\n";
          }

          MessageBox.Show(checkedItems);

          Regards, Polis Can you practice what you teach?

          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