I try to drag items from a listview to a Treeview.
I use the following code but I don't know how to do the folowing points :
1 - Check if data dragged onto the treeview is listview item collection
2 - When dragdrop, retrieving data from the listview item collection dropped
Thanks in advance ;-)
here is my code :
VB Code:
Private Sub ListView1_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles ListView1.ItemDrag ListView1.DoDragDrop(ListView1.SelectedItems, DragDropEffects.Copy Or DragDropEffects.Move) End Sub Private Sub TreeView1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragOver Dim Pt As Point Dim Node As TreeNode 'If Not (TypeOf sender Is ListView.SelectedListViewItemCollection) Then Exit Sub 'If e.Data.GetDataPresent(GetType(System.Windows.Forms.ListView.ListViewItemCollection)) = True Then Pt = TreeView1.PointToClient(New Point(e.X, e.Y)) Node = TreeView1.GetNodeAt(Pt) If Microsoft.VisualBasic.Left(Node.Tag, 7) = "AGENT " Then e.Effect = DragDropEffects.Move Else e.Effect = DragDropEffects.None End If 'End If End Sub Private Sub TreeView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragDrop Dim Result As DialogResult 'popup confirmation du move Result = MsgBox("Etes vous sure de vouloir transférer les dossier ?", MsgBoxStyle.YesNo, "Transfer dossier") If Result = DialogResult.No Then Exit Sub 'update agent traitant des dossiers concerné par le nouvel agent Dim Items As ListView.ListViewItemCollection() Items = CType(e.Data.GetData(GetType(System.Windows.Forms.ListView.ListViewItemCollection)), ListView.ListViewItemCollection()) 'refresh treeview End Sub




Reply With Quote