Results 1 to 5 of 5

Thread: [RESOLVED] List View to ListBox thingy

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Resolved [RESOLVED] List View to ListBox thingy

    Hey guys I have a listview called lvwfound and I was wondering, how do I click on a item that added to the list view to a list box thing.


    The code that adds thigns to the list view is

    VB Code:
    1. Dim i As Integer
    2. Dim item As String
    3. Dim iResponce As Integer
    4. i = Me.lvwFound.ListItems.Count 'list count
    5. For i = 0 To i - 1
    6.     'MsgBox Me.lvwFound.ListItems(i + 1)
    7.     item = Me.lvwFound.ListItems(i + 1)
    8.    
    9. '

    Would i replace lvwfound with list4 ? Also i there a click event for a listview so only when I click on items in a listview it will add that item to a listbox?

    Thank you.
    Last edited by Hack; Sep 10th, 2007 at 06:21 AM. Reason: Added RESOLVED to thread title and green resolved checkmark

  2. #2
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: List View to ListBox thingy

    Well, couldnt understand the question clerarly, but found two ways to add the selected items to the list box (List1). Check it out

    Code:
    Private Sub ListView1_Click()
        Dim i As Integer
        Dim lstItem As ListItem
        
        List1.Clear
        List1.Refresh
        
        For Each lstItem In ListView1.ListItems
            If lstItem.Selected = True Then
                List1.AddItem ListView1.ListItems(lstItem.Index)
            End If
        Next
    End Sub
    or
    Code:
    Private Sub ListView1_Click()    
         List1.AddItem ListView1.SelectedItem
    End Sub
    hope this is what you are looking for.

    IIF(Post.Rate > 0 , , )

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: List View to ListBox thingy

    thank you that works great. One more question would be, can an item be removed? Like if there was a item on the list1 listbox and i clicked on it in the listbox would it go away?

    thanks

  4. #4
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: List View to ListBox thingy

    ya, its simple

    Code:
    Private Sub List1_Click()
        List1.RemoveItem List1.ListIndex
    End Sub
    IIF(Post.Rate > 0 , , )

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: List View to ListBox thingy

    Thank you for all your help bud cheers!!!!

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