Results 1 to 3 of 3

Thread: select list from the listview

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    select list from the listview

    I have the listview. I would like to display the filename and the path location in the textbox when I select the list from the listview. Any idea? Just want to learn how I can read the list items from listview and show it in the 2 textbox.Have a sample to test with ?
    text1.text = filename
    text2.text = path location.


    Code:
    For i = 1 To ListView1.ListItems.Count
        If ListView1.ListItems.Item(i).Selected Then
    'what should I do
        End If
    Next i
    Attached Images Attached Images  

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: select list from the listview

    If you ask to pass to textbox value from the second column then it's a subitem.
    You may want to set Multiline = True for your textbox before running this:
    Code:
    For i = 1 To ListView1.ListItems.Count
        If ListView1.ListItems.Item(i).Selected Then
            Text2.Text = Text2.Text & ListView1.ListItems.Item(i).Subitems(1) & vbNewLine
        End If
    Next i

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: select list from the listview

    Why when I click anywhere in the listview,it show me the path location in the textbox. The textbox should show the path location only selected item. I put my code in the click event.

    Private Sub ListView1_Click()
    For i = 1 To ListView1.ListItems.Count
    If ListView1.ListItems.Item(i).Selected Then
    Text2.Text = ListView1.ListItems.Item(i).Subitems(1) & vbNewLine
    End If
    Next i

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