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 access

listbox - valuemember access

Scheduled Pinned Locked Moved C#
helptutorialquestion
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.
  • M Offline
    M Offline
    madhusri
    wrote on last edited by
    #1

    Hi all, I would like to know of how to get the value member of every item in the listbox. It is clear that i can get the valumember of the selected item using the selectedvalue property. But my requirement is that i need to check the values of all the items immaterial of if it is selected or not. How can this be achieved? please help me out with this. Thanks in advance Regards, Madhusri Thanks and Regards MadhuSri

    S 1 Reply Last reply
    0
    • M madhusri

      Hi all, I would like to know of how to get the value member of every item in the listbox. It is clear that i can get the valumember of the selected item using the selectedvalue property. But my requirement is that i need to check the values of all the items immaterial of if it is selected or not. How can this be achieved? please help me out with this. Thanks in advance Regards, Madhusri Thanks and Regards MadhuSri

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Try this one:

      for (int index = 0; index < listBox.Items.Count; index++)
      {
      PropertyInfo info = listBox.Items[index].GetType().GetProperty(listBox.ValueMember);
      object valuemember = info.GetValue(listBox.Items[index], null);
      }


      www.troschuetz.de

      M 1 Reply Last reply
      0
      • S Stefan Troschuetz

        Try this one:

        for (int index = 0; index < listBox.Items.Count; index++)
        {
        PropertyInfo info = listBox.Items[index].GetType().GetProperty(listBox.ValueMember);
        object valuemember = info.GetValue(listBox.Items[index], null);
        }


        www.troschuetz.de

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

        Stefan Troschütz wrote:

        for (int index = 0; index < listBox.Items.Count; index++) { PropertyInfo info = listBox.Items[index].GetType().GetProperty(listBox.ValueMember); object valuemember = info.GetValue(listBox.Items[index], null);}

        Stefan, thanks for the sample code. it helped me to get the valuemamber. Thanks and Regards Madhu

        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