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. ListBox ValueMember

ListBox ValueMember

Scheduled Pinned Locked Moved C#
databasedata-structuresperformancetutorialquestion
3 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.
  • A Offline
    A Offline
    adityap
    wrote on last edited by
    #1

    Hi, Can we have a ListBox ValueMember Collection? If we have SelectionMode as MultiExtended, and we select more than one values in the listbox, then can we show its respective value member as we can show the SelectedIndices (Collection of selected index) If there is a way could you please post an example with it.. And if there is not then What are the alternatives (without using and temp array to kepp track of it..some memory mgmt is required here) Thanks a lot

    R 1 Reply Last reply
    0
    • A adityap

      Hi, Can we have a ListBox ValueMember Collection? If we have SelectionMode as MultiExtended, and we select more than one values in the listbox, then can we show its respective value member as we can show the SelectedIndices (Collection of selected index) If there is a way could you please post an example with it.. And if there is not then What are the alternatives (without using and temp array to kepp track of it..some memory mgmt is required here) Thanks a lot

      R Offline
      R Offline
      rah_sin
      wrote on last edited by
      #2

      try out following codes for(int i=0;i < listBox1.Items.Count;i++) { if(listBox1.GetSelected(i)) { MessageBox.Show("",listBox1.GetItemText(listBox1.Items[i])); } } rahul -- modified at 5:25 Thursday 11th May, 2006

      A 1 Reply Last reply
      0
      • R rah_sin

        try out following codes for(int i=0;i < listBox1.Items.Count;i++) { if(listBox1.GetSelected(i)) { MessageBox.Show("",listBox1.GetItemText(listBox1.Items[i])); } } rahul -- modified at 5:25 Thursday 11th May, 2006

        A Offline
        A Offline
        adityap
        wrote on last edited by
        #3

        This would work absolutely fine, but you did not get my problem I am displaying some value in the listbox and actually require some different value, say for e.g. i am showing names in the box whereas if the user selects a name i am retriving the corresponding employee ID for that name. Now this scenario is possible through ValueMember and DisplayMember property of ListBox. DisplayMember = name ValueMember = empId Now the code which you gave me works fine if i need to retrive the DisplayMembers from listbox.. My question though,here was i needed the ValueMembers to corresponding selection Thanks a lot -- modified at 6:14 Thursday 11th May, 2006

        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