Hi Pooja-
You can implement drag and drop with the DataObject (the "clipboard" ).
In the form that hosts the TreeView control (perhaps in the TreeViews
MouseMove Event):
Private Sub treeFileInfoTre e_MouseMove(ByV al sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles treeFileInfoTre e.MouseMove
Dim tBase as TreeView
Dim data as New DataObject
'If no mouse button pressed, then assume no dragdrop
If e.Button = MouseButtons.No ne Then Exit Sub
tBase = DirectCast(send er, TreeView)
'Exit sub if button pressed but mouse is not over treeview node
If tBase.SelectedN ode.Bounds.Cont ains(e.X, e.Y) Then Exit Sub
'Assign data to clipboard
data.SetData(Da taFormats.Text, tBase.SelectedN ode.Text)
'Begin Drag Operation
Dim effect As DragDropEffects = DragDropEffects .Copy
effect = tBase.DoDragDro p(data, effect) 'wait here until drop complete
End Sub
Then you need to add code to the DragDrop event of the control where the
drop is occuring:
Private Sub ListBox1_DragDr op(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles lstOriginal.Dra gDrop
Dim lBase As ListBox = DirectCast(send er, ListBox)
lBase.Items.Add (e.Data.GetData (DataFormats.Te xt).ToString)
End Sub
"pooja" wrote:
i need to implement drag and drop in treeview in VB.
Kindly help.
My treeview contains activities maintained using XML Files.
Hopefully, Thanks.