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. Windows Forms
  4. listbox question

listbox question

Scheduled Pinned Locked Moved Windows Forms
questiondatabasewinforms
5 Posts 3 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.
  • L Offline
    L Offline
    loyal ginger
    wrote on last edited by
    #1

    In my Windows Forms application I have a listbox on the form. This is a multiple selection list box. I can use SelectedIndices property to get the indices of all the selected items. However, given an index number, is there a simple way to tell if the item is selected or not? Right now I search the SelectedIndices to see if the index is there. I wonder if there is a method call to tell me directly if an item is selected or not. I tried to find that but couldn't. Thanks!

    L 1 Reply Last reply
    0
    • L loyal ginger

      In my Windows Forms application I have a listbox on the form. This is a multiple selection list box. I can use SelectedIndices property to get the indices of all the selected items. However, given an index number, is there a simple way to tell if the item is selected or not? Right now I search the SelectedIndices to see if the index is there. I wonder if there is a method call to tell me directly if an item is selected or not. I tried to find that but couldn't. Thanks!

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, you could try listBox.Items.Contains(...) :)

      Luc Pattyn


      I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


      L L 2 Replies Last reply
      0
      • L Luc Pattyn

        Hi, you could try listBox.Items.Contains(...) :)

        Luc Pattyn


        I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


        L Offline
        L Offline
        loyal ginger
        wrote on last edited by
        #3

        That works. Thanks!

        L 1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, you could try listBox.Items.Contains(...) :)

          Luc Pattyn


          I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          it should be listBox.SelectedIndices.Contains(...) listBox.Items.Contains(...) will be true for all items.

          1 Reply Last reply
          0
          • L loyal ginger

            That works. Thanks!

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            its really works ?

            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