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. listview displaymember prpperty problem (Pls Help)

listview displaymember prpperty problem (Pls Help)

Scheduled Pinned Locked Moved C#
helpcsharpdatabasequestionworkspace
4 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.
  • V Offline
    V Offline
    vipinpaliwal1980
    wrote on last edited by
    #1

    ListBox DataSource DisplayMember Property Problems in C# I have a (single select) listbox with data and when I click on the list I can't get the right text selected. My listbox is setup using the DataSource property. I set my ValueMember and DisplayMember listBox1.ValueMember = "TypeID"; listBox1.DisplayMember = "Name"; I am able to get the "TypeID" (ValueMember) when I click on the items. I do that like this... int intTest; intTest = System.Int32.Parse(listBox1.SelectedValue.ToString ()); But I can't get the text (DisplayMember). I have used these two ways, but... string strDispMem; strDispMem = listBox1.Items[index].ToString(); // the above returns... "System.Data.DataRowView" or strDispMem = listBox1.Text; // The above repeats first selection the user clicks on. Any ideas??? vipin Paliwal

    C R 2 Replies Last reply
    0
    • V vipinpaliwal1980

      ListBox DataSource DisplayMember Property Problems in C# I have a (single select) listbox with data and when I click on the list I can't get the right text selected. My listbox is setup using the DataSource property. I set my ValueMember and DisplayMember listBox1.ValueMember = "TypeID"; listBox1.DisplayMember = "Name"; I am able to get the "TypeID" (ValueMember) when I click on the items. I do that like this... int intTest; intTest = System.Int32.Parse(listBox1.SelectedValue.ToString ()); But I can't get the text (DisplayMember). I have used these two ways, but... string strDispMem; strDispMem = listBox1.Items[index].ToString(); // the above returns... "System.Data.DataRowView" or strDispMem = listBox1.Text; // The above repeats first selection the user clicks on. Any ideas??? vipin Paliwal

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

      listBox1.SelectedText ( from memory ) - it's something like that.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      V 1 Reply Last reply
      0
      • C Christian Graus

        listBox1.SelectedText ( from memory ) - it's something like that.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        V Offline
        V Offline
        vipinpaliwal1980
        wrote on last edited by
        #3

        i not understand what u say, sorry. pls give me brif vipin paliwal

        1 Reply Last reply
        0
        • V vipinpaliwal1980

          ListBox DataSource DisplayMember Property Problems in C# I have a (single select) listbox with data and when I click on the list I can't get the right text selected. My listbox is setup using the DataSource property. I set my ValueMember and DisplayMember listBox1.ValueMember = "TypeID"; listBox1.DisplayMember = "Name"; I am able to get the "TypeID" (ValueMember) when I click on the items. I do that like this... int intTest; intTest = System.Int32.Parse(listBox1.SelectedValue.ToString ()); But I can't get the text (DisplayMember). I have used these two ways, but... string strDispMem; strDispMem = listBox1.Items[index].ToString(); // the above returns... "System.Data.DataRowView" or strDispMem = listBox1.Text; // The above repeats first selection the user clicks on. Any ideas??? vipin Paliwal

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

          try out for(int i=0;i < listBox1.Items.Count ; i++ ) { if(listBox1.GetSelected(i)) { strDispMem = listBox1.GetItemText(listBox1.Items[i]); } } -- modified at 7:38 Tuesday 31st October, 2006

          rahul

          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