有点不是很完美
窗口afterload事件
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
Dim listView1 As System.Windows.Forms.ListView = lvw.BaseControl
AddHandler listView1.DragDrop, AddressOf ListView1_DragDrop
全局代码
Public Sub listView1_DragDrop( sender As Object, e As System.Windows.Forms.DragEventArgs)
Dim listView1 As System.Windows.Forms.ListView = sender
Dim draggedItem As System.Windows.Forms.ListViewItem = e.Data.GetData(GetType(System.Windows.Forms.ListViewItem))
'Output.Show("draggedItem.text=" & draggedItem.Text)
Dim point As Point = listView1.PointToClient(New Point(e.X, e.Y))
Dim targetItem As System.Windows.Forms.ListViewItem = listView1.GetItemAt(point.X, point.Y)
If targetItem IsNot Nothing Then
Dim newGroup As System.Windows.Forms.ListViewGroup = targetItem.Group
' Output.Show("newGroup=" & (newGroup Is Nothing))
If newGroup IsNot Nothing Then
Output.Show("newGroup=" & newGroup.Name)
draggedItem.Group = newGroup
Output.Show("targetItem.Index=" & targetItem.Index)
End If
End If
End Sub