Murray Brown
asked on
VB.net problem dragging text into DataGridView
Hi. I am trying to drag the name of a TreeView node (shown at the bottom) into a DataGridView cell. I gather the text using oText below but I get
"System.Windows.Forms.Drag EventArgs"
Private Sub DataGridView1_DragDrop(sen der As Object, e As System.Windows.Forms.DragE ventArgs) Handles DataGridView1.DragDrop
Dim oText as string = e
Private Sub TreeView_From_DragEnter(se nder As Object, e As System.Windows.Forms.DragE ventArgs) Handles TreeView_From.DragEnter
'See if there is a TreeNode being dragged
If e.Data.GetDataPresent("Sys tem.Window s.Forms.Tr eeNode", _
True) Then
'TreeNode found allow move effect
'e.Effect = DragDropEffects.Move
e.Effect = DragDropEffects.All
Else
'No TreeNode found, prevent move
e.Effect = DragDropEffects.None
Exit Sub
End If
"System.Windows.Forms.Drag
Private Sub DataGridView1_DragDrop(sen
Dim oText as string = e
Private Sub TreeView_From_DragEnter(se
'See if there is a TreeNode being dragged
If e.Data.GetDataPresent("Sys
True) Then
'TreeNode found allow move effect
'e.Effect = DragDropEffects.Move
e.Effect = DragDropEffects.All
Else
'No TreeNode found, prevent move
e.Effect = DragDropEffects.None
Exit Sub
End If
ASKER
Hi. That still gives System.Windows.Forms.DataO bject
ASKER
I don't understand this because in the drag I used
DoDragDrop(e.Item.text, DragDropEffects.All)
and when I drop it into Excel it works as text
DoDragDrop(e.Item.text, DragDropEffects.All)
and when I drop it into Excel it works as text
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Open in new window
rather than the plain data. youcan also look at using the GetDataPresent() method (or indeed check the type of the data to extract the node name / text values)