Results 1 to 2 of 2

Thread: ListView Question

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Location
    Phoenx, AZ
    Posts
    15

    ListView Question

    I want to be able to add the text to each of my columns in my listview (Which I can do), but I also want to add an ID Number (From my database) for that row of listviewitems. I then want to be able to click on that row in my listview and get the ID number. What property is used for an ID Number in a listview in .net. With the combobox you have the .valuemember, is there something similar with the listview? Anybody have any code examples of doing this? Thanks in advance for your time.

    Here's my code (This works to add the text)

    While drSearch.Read

    Dim lvi As New ListViewItem
    lvi.Text = drSearch.Item("Company_Name").ToString(),

    With lvi

    .SubItems.Add(drSearch.Item("Web_Site").ToString())
    .SubItems.Add(drSearch.Item("Industry").ToString())

    End With

    lstViewSearchResults.Items.Add(lvi)

    End While

  2. #2
    Lively Member nokia8210's Avatar
    Join Date
    Dec 2002
    Location
    Coventry
    Posts
    92
    When u fill the rows where you have:

    lvi.Text = drSearch.Item("Company_Name").ToString(),

    put under it

    lvi.Tag = (ur ID Number here)

    to check if its working put in the lstview_ItemActivate Event

    msgbox(lvi.selecteditems(0).tag)

    that sould sort it

    you can then use the lvi.selecteditems(0).tag to pass the value to where ever you want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width