Hi guys!
I feel very funny because this is the first time that i'm asking a question in a forum. I'm gonna try to describe my problem as clear as possible cuz' i'm not that good with english.
I'm trying to program a 'drag and drop' from one treeview to another. I know it's very easy to manage it but i want to make it look like u really drag the node text from the tree view.
This is what i did so far:
I created a windows form with a label and with a transparency key so that only the label will be visible. I have set the form TopMost to True and declared it in the main form where I should do the drag.
On the mousedown event of the treeview from which the name should be dragged, i relocated the moving form to the treenode and gave the text of the treenode.
The code looks like this:
Private Sub treeFrom_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles treeFrom.MouseDown
Dim name As String
Dim key As String
If Not treeFrom.GetNodeAt(e.Location) Is Nothing Then
key = treeFrom.GetNodeAt(e.Location).Tag
name = treeFrom.Nodes(key).Text
frm.SetTheLabelName(name)
frm.Location = New Point(Me.Location.X + sender.Location.X + e.Location.X, Me.Location.Y + sender.Location.Y + e.Location.Y)
blnDrag = True
End If
End Sub
The new location of the form is still not perfect but i will manage it so the label text of the form will fit exactly above the treenode text.
This is the mousemove event of the treenode:
Private Sub treeFrom_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles treeFrom.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
frm.Location = New Point(Me.Location.X + treeFrom.Location.X + e.Location.X, _
Me.Location.Y + treeFrom.Location.Y + e.Location.Y)
End If
End Sub
I also managed it to move over the form with the mousemove form event but the problem is that i have to program it for MouseMove event of each control.
Is there any way to manage it only with the form MouseMove event because when i catch the moving form from one event to other the label jump from one location to the other, and i want it to do the transition smoothly. A great way would be jumping directly from the TreeFrom_MouseDown event to the MouseMove event of the moving form but I don't know if that is possilbe somehow.