RazerWriter Posted July 1, 2003 Posted July 1, 2003 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! Quote
*Experts* Volte Posted July 1, 2003 *Experts* Posted July 1, 2003 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. Quote
RazerWriter Posted July 1, 2003 Author Posted July 1, 2003 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 ___________________________________________ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.