Results 1 to 2 of 2

Thread: listview subitems

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    33

    listview subitems

    I have a listview and I want to set it up so when you click on an item that item's subitem get put into a variable. How do i do this in VB.NET?

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    First set the listview's property MultiSelect to false (to make sure the user is only able to select one item at a time), then add code to the lvwItems.Click event:

    Code:
        Private Sub lvwItems_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwItems.Click
            Dim strFoo As String = lvwItems.SelectedItems(0).SubItems(1).Text
            MsgBox(strFoo)
        End Sub
    SelectedItems(0) will be the first (only) selected item in the ListView.SelectedItems collection. Subitems begin counting at 1, not zero.

    ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwindowsformslistviewitemlistviewsubitemclasstopic.htm

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