Posted 5 June 2024, 6:37 am EST
Hello Said,
Thank you for providing the sample.
For dragging and dropping a file in C1TreeView, you can set AllowDrop to true and handle the DragEnter and DragDrop events of C1TreeView, and to get the parent node, you can use the node.ParentCollection.Parent property as follows:
C1TreeView1.AllowDrop = True
AddHandler C1TreeView1.DragEnter, AddressOf C1TreeView1_DragEnter
AddHandler C1TreeView1.DragDrop, AddressOf C1TreeView1_DargDrop
.
.
.
Private Sub C1TreeView1_DragEnter(sender As Object, e As DragEventArgs)
If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy
End Sub
Private Sub C1TreeView1_DargDrop(sender As Object, e As DragEventArgs)
Dim node = C1TreeView1.GetNodeAtPoint(C1TreeView1.PointToClient(New Point(e.X, e.Y)))
Dim data = e.Data.GetData(DataFormats.FileDrop)
If IsNothing(data) Then Return
node(0) = DirectCast(data, String())(0)
MessageBox.Show($"Node val: {node(0)}{vbNewLine}NodeParent val: {node.ParentCollection?.Parent?(0)}")
End Sub
Please refer to the attached modified sample for implementation. (see TreeView_Win_Mod.zip)
In the sample, we have displayed the path of the file dropped to the C1TreeView.
If you have a different requirement, please share more details on your use case so that we can assist you accordingly.
Regards,
Uttkarsh.