Hello everyone.
I have a little problem, as always, I hope you will help me to solve. I have a TreeView with nodes and subnodes and that a panel should receive information about the clicked node and carried.
In this way I wish I could put more markets on the same panel. If I click on the treeview = start Added: Drag & Drop = successive engagements
I created this sub on the treeview
Code:
Private Sub tvMarkets_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles tvMarkets.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
While these other two relate to the Panel that receives:
Code:
Private Sub tbox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles tbox.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub tbox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles tbox.DragDrop
Dim dummy As String = "hello"
Dim s As String = CStr(e.Data.GetData(dummy.GetType()))
s = s.Substring((s.IndexOf(":") + 1)).Trim()
Position.X = e.X
Position.Y = e.Y
Position = tbox.PointToClient(Position)
MsgBox(s)
End Sub
The problem is that the code tells me, via the msgbox (s) as the name of the text node and not the Node.Name that interests me.
Do you have a way to solve my problem?
I enclose also the code that gives me 'is this information if I click on the affected node without of course the drag and drop.
Code:
Private Sub tvMarkets_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvMarkets.AfterSelect
If e.Node.Nodes.Count = 0 Then
Dim marketId As Integer = Val(e.Node.Name) 'This is the selected marketId
End If
End Sub


Leave a comment: