Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I don't understand how to use the Vb NET drag and drop events. I want to add an item to a Tree View when the user drops text onto it. How do I do this?

 

Please respond quickly. I am short on time with this project. Thank you!

  • *Experts*
Posted

Set the TreeView's "AllowDrop" property to True, and then use the TreeView's "DragDrop" event to capture the dragging and dropping of an object.

 

You can use the "GetNodeAt()" method of the TreeView to find the tree node that is at the point you dropped on. The drop point is stored in the DragEventArgs in the event as e.X and e.Y.

Posted

still doesn't work. I can't drop anything onto the treeview. The cursor doesn't change or anything.

 

here is the code:

 

___________________________________________

 

Private Sub TreeView1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SiteTree.DragDrop

 

Dim dropp As New System.Drawing.Point

dropp.X = e.X

dropp.Y = e.Y

 

Dim newNode As System.Windows.Forms.TreeNode

newNode = New System.Windows.Forms.TreeNode

With newNode

.SelectedImageIndex = 1

.ImageIndex = 1

.Text = e.Data.GetData(System.Windows.Forms.DataFormats.Html Or System.Windows.Forms.DataFormats.Rtf Or System.Windows.Forms.DataFormats.Text Or System.Windows.Forms.DataFormats.UnicodeText)

.Checked = True

End With

TreeView1.GetNodeAt(dropp).Nodes.Add(newNode)

End Sub

___________________________________________

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...