Results 1 to 8 of 8

Thread: copy selected listview to listbox

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    copy selected listview to listbox

    How can i copy all the selected items in a multiselect listview to a listbox
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: copy selected listview to listbox

    This seems to work, puts a comma between the items.

    edit: fix
    Code:
         
        Dim x As Integer, y As Integer
        Dim l$
    
        For x = 1 To ListView1.ListItems.Count
            If ListView1.ListItems.Item(x).Selected = True Then
                l$ = l$ & ListView1.ListItems.Item(x).Text & ","
                
                For y = 1 To ListView1.ListItems.Item(x).ListSubItems.Count
                    l$ = l$ & ListView1.ListItems.Item(x).SubItems(y) & ","
                Next y
                List1.AddItem Mid$(l$, 1, Len(l$) - 1)  ' removes last comma
            End If
            
        l$ = ""
        Next x

  3. #3

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: copy selected listview to listbox

    Quote Originally Posted by Edgemeal
    This seems to work, puts a comma between the items.

    edit: fix
    Code:
         
        Dim x As Integer, y As Integer
        Dim l$
    
        For x = 1 To ListView1.ListItems.Count
            If ListView1.ListItems.Item(x).Selected = True Then
                l$ = l$ & ListView1.ListItems.Item(x).Text & ","
                
                For y = 1 To ListView1.ListItems.Item(x).ListSubItems.Count
                    l$ = l$ & ListView1.ListItems.Item(x).SubItems(y) & ","
                Next y
                List1.AddItem Mid$(l$, 1, Len(l$) - 1)  ' removes last comma
            End If
            
        l$ = ""
        Next x
    Thanks that works
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: copy selected listview to listbox

    l$ = l$ & ListView1.ListItems.Item(x).Text & ","
    should just be,
    l$ = ListView1.ListItems.Item(x).Text & ","
    since theres nothing in L$ yet anyway.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: copy selected listview to listbox

    Quote Originally Posted by isnoend07
    How can i copy all the selected items in a multiselect listview to a listbox
    Why would you want to do this? If you have multiple columns, the ListView is the perfect control. A listbox does not have the column manipulation available in a Listview.

  6. #6

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: copy selected listview to listbox

    Quote Originally Posted by Hack
    Why would you want to do this? If you have multiple columns, the ListView is the perfect control. A listbox does not have the column manipulation available in a Listview.
    Maybe you know a better way.
    I send emails with attachments. The user can open his wab file in windows and fill a list view with icons. They can select items then clicking buttons fills 3 listboxs To, Cc and Bcc for email recipients. Like outlook does. Do you know a better way?
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: copy selected listview to listbox

    Instead of 3 listboxs why one one additional ListView with three columns?

  8. #8

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: copy selected listview to listbox

    Quote Originally Posted by Hack
    Instead of 3 listboxs why one one additional ListView with three columns?
    That would probably work for someone who is experienced at using a listview, but i got listboxs dialed in. As items may need to be removed
    from the lisboxs(removeitem) and the transfered to the fields in the email program, seperated by (";") all this will be easy using listboxs. if fact i would not even use the listView if i could put icons into a listbox
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

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