Hi how can i allow the user to drag a item from a listview to a
listbox and in the listbox a subitem is shown as items text
Printable View
Hi how can i allow the user to drag a item from a listview to a
listbox and in the listbox a subitem is shown as items text
What exactly does this mean ???Quote:
... and in the listbox a subitem is shown as items text
Amazing what you can learn in a quarter of an hour, I'd never done any OLE drag/drop before. Needs a listbox and a listview, no props changed.
VB Code:
Option Explicit Private Sub Form_Load() Dim lvItem As ListItem Set lvItem = ListView1.ListItems.Add(, , "weee") List1.OLEDropMode = ccOLEDropManual With ListView1 .OLEDragMode = ccOLEDragAutomatic .View = lvwReport .FullRowSelect = True Call .ColumnHeaders.Add(, , "bleh") Call .ColumnHeaders.Add(, , "bleh2") End With lvItem.SubItems(1) = "hi" End Sub Private Sub List1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) Dim sData As String sData = Data.GetData(vbCFText) If Data.GetFormat(vbCFText) Then Call List1.AddItem(sData) End If End Sub Private Sub ListView1_OLESetData(Data As MSComctlLib.DataObject, DataFormat As Integer) 'Just change the number below to send a different sub item Call Data.SetData(ListView1.SelectedItem.SubItems(1)) End Sub 'The below procs should stop other programs from being _ able to drop onto the listbox.. in theory Private Sub ListView1_OLECompleteDrag(Effect As Long) List1.OLEDropMode = ccOLEDropNone End Sub Private Sub ListView1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long) List1.OLEDropMode = ccOLEDropManual End Sub