how can i drag a node, from a tree view control, into a textbox, and have it show the title of the node?
Printable View
how can i drag a node, from a tree view control, into a textbox, and have it show the title of the node?
In the treeview's MouseDown event;
Treeview1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button=1 Then Exit Sub
'only drag with right mouse button
Treeview1.SelectedItem = Treeview1.HitTest(X, Y)
Treeview1.DragIcon = Treeview1.SelectedItem.CreateDragImage
Treeview1.Drag 1
End Sub
Make sure the treeview's dragmode property is Manual.
You can get away without the TreeView1.DragIcon=.... line if you set a DragIcon in the treeview properties - otherwise it uses whatever icon is displayed on the treeview for that item.
In the text box's DragDrop event;
Private Sub txtView_DragDrop(Source As Control, X As Single, Y As Single)
If Source.Name = "Treeview1" Then
txtView.Text = Source.SelectedItem.Text
End If
End Sub
thankyou very much, but what does "Hittest" do ?
.HitTest is a method of the treeview that determines which item the mouse is over based on the X and Y co-ordinates. You need it to determine which item you're dragging..
thank you veryt much :)
Can anyone tell me how to do this with VB.Net.
probably, if you ask in the Net forum :bigyello:
Add the checkmark, and the word [RESOLVED] to your first post in this thread if it is resolved.