Hi All,
I use two Listviews. I want to drag and drop items from Listview1 to
Listview2.
I use following code:
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x
As Single, y As Single)
If Button = vbLeftButton Then
ListView1.OLEDragMode = vbOLEDragAutomatic
ListView1.OLEDrag
End If
End Sub
Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x
As Single, y As Single)
ListView1.OLEDragMode = vbOLEDragManual
End Sub
Private Sub ListView2_OLEDragDrop(Data As MSComctlLib.DataObject,
Effect As Long, Button As Integer, Shift As Integer, x As Single, y As
Single)
Dim itmX As ListItem
Dim cnt As Integer
Dim numSelected As Long
numSelected = SendMessage(ListView1.hwnd, _
LVM_GETSELECTEDCOUNT, _
0&, _
ByVal 0&)
For cnt = numSelected To 1 Step -1
Set itmX = ListView2.ListItems.Add(, , Data.GetData(vbCFText), ,
4)
itmX.SubItems(1) = ListView1.ListItems(cnt).ListSubItems(1).Text
itmX.SubItems(2) = ListView1.ListItems(cnt).ListSubItems(2).Text
ListView1.ListItems.Remove (cnt)
Next
End Sub
The problem is that the code doesn't know which items were selected.
So I get all the same items at Listview2
Marco
huszarnezsuzsa@globonet.hu - 17 Aug 2007 23:06 GMT
Hazugság!!!!!!!!!!!!!!!!!!!!!!!!!
"vonClausowitz" <vonclausowitz@gmail.com> az alábbiakat írta a következõ
hírüzenetben: 1187386253.763912.196320@57g2000hsv.googlegroups.com...
> Hi All,
>
[quoted text clipped - 47 lines]
>
> Marco
vonClausowitz - 17 Aug 2007 23:33 GMT
On 18 aug, 00:06, <huszarnezsu...@globonet.hu> wrote:
> Hazugs?g!!!!!!!!!!!!!!!!!!!!!!!!!
> "vonClausowitz" <vonclausow...@gmail.com> az al?bbiakat ?rta a k?vetkez?
[quoted text clipped - 51 lines]
>
> > Marco
What do you mean with Story?
MArco
Mark Yudkin - 22 Aug 2007 18:00 GMT
You need to do this yourself by coding the relevant DataObject object in the
ListView1_OLESetData event. You should not rely on "current selection" after
the drop has occured, but set it up when the drag starts. I would also
strongly recommend complete avoidance of vbOLEDragAutomatic, as it probably
doesn't do what you want, and attempts to mix manual and automatic mode are
prone to problems.
> Hi All,
>
[quoted text clipped - 47 lines]
>
> Marco