|
-
Jul 17th, 2010, 05:44 PM
#1
Thread Starter
Lively Member
[RESOLVED] Copying Selected ListView Items
Hi,
I'm having some minor issues right now in trying to get a selected row copied over from a ListView control to another ListView control. Assuming they have the same number of columns - could someone help out? I tried searching but ran into a thread where a guy needed help getting them into a ListBox control - it wasn't helpful at all. Did a google search and came across:
http://vbcity.com/forums/p/132841/567620.aspx
I just don't know how I'd apply it to this current project.
Could one of you guys code it out assuming one of my controls is called sourceListView and the second is called destinationListView? I was thinking about doing it on an ItemClick event.
Thanks in advanced, I will add to reputation.
-
Jul 17th, 2010, 07:01 PM
#2
Re: Copying Selected ListView Items
Here's an example for the ItemClick event.
vb Code:
Option Explicit
Private Sub Form_Load()
Dim i As Long
'Here we setup the Listview. This is just an example.
sourceListView.ColumnHeaders.Add , , "Column 1", 1500
sourceListView.ColumnHeaders.Add , , "Column 2", 1500
sourceListView.ColumnHeaders.Add , , "Column 3", 1500
destinationListView.ColumnHeaders.Add , , "Column 1", 1500
destinationListView.ColumnHeaders.Add , , "Column 2", 1500
destinationListView.ColumnHeaders.Add , , "Column 3", 1500
sourceListView.FullRowSelect = True
destinationListView.FullRowSelect = True
sourceListView.View = lvwReport
destinationListView.View = lvwReport
For i = 1 To 10
sourceListView.ListItems.Add , , "Item " & i
sourceListView.ListItems(i).SubItems(1) = "SubItem " & i
sourceListView.ListItems(i).SubItems(2) = "SubItem " & i
Next i
End Sub
Private Sub sourceListView_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim i As Long
destinationListView.ListItems.Add , , Item.Text
For i = 1 To Item.ListSubItems.Count
destinationListView.ListItems(destinationListView.ListItems.Count).SubItems(i) = Item.SubItems(i)
Next i
End Sub
-
Jul 17th, 2010, 08:04 PM
#3
Thread Starter
Lively Member
Re: Copying Selected ListView Items
Thanks, works perfectly. Rated up.
-
Jul 18th, 2010, 04:51 AM
#4
Re: Copying Selected ListView Items
Please also take time to mark the thread as Resolved. You can do so by going to the Thread Tools menu which is on the right side, above your original post, and choosing Mark Thread Resolved.
-
Jul 22nd, 2010, 09:12 PM
#5
Thread Starter
Lively Member
Re: [RESOLVED] Copying Selected ListView Items
Thread has been resolved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|