We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Tree View Drag Drop Option

Vey Very Urgent.. I want to drag a item from a tree view control and move it on the form area and drop the item.once the item is dropped on the form , i want to create a label with the caption text of the label as the dragged node value.... please please do reply......

6 Replies

AD Administrator Syncfusion Team May 10, 2005 04:02 PM

Hi Sayed, Please refer to the following KB article for information on this : How do I perform the drag drop operation between an XPToolBar and TreeViewAdv ? Let me know if you need further assistance. Regards, Guru Patwal Syncfusion, Inc.


SI Sayed Ismail May 11, 2005 10:17 AM

Hi Guru First of i would like to thank you for quick reply. KB article was of quite help. The sample code was in C# but i manged to convert it into VB code and i could create a label on the form during drag drop operation. But its a round about solution which helped me to continue with my work ahead. below the code showing what i have done. please go through it and see if you can give me a better solution. But please i would be gratefull if something in VB.net... ;-) i have placed a TreeView control With the name "DataSource" on the form ,having form name as "FORM1"....i have set the allowdrop property of the form to "TRUE" these are the four events i have used to achieve my task Dim labelText as String Private Sub DataSource_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataSource.MouseDown Try If e.Button = MouseButtons.Left Then Dim p As Point p = DataSource.PointToClient(Control.MousePosition) Dim node As TreeNodeAdv node = DataSource.PointToNode(p) DataSource.SelectedNode = node DataSource.Refresh() Labeltext = node.Text End If Catch ex As Exception End Try End Sub Private Sub DataSource_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles DataSource.ItemDrag Try Dim treeViewAdv As TreeViewAdv = CType(sender, TreeViewAdv) Dim nodes As TreeNodeAdv() = CType(e.Item, TreeNodeAdv()) Dim node As TreeNodeAdv = nodes(0) treeViewAdv.DoDragDrop(node.Text, DragDropEffects.Move Or DragDropEffects.Copy) Catch ex As Exception End Try End Sub Private Sub Form1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter e.Effect = DragDropEffects.Copy End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove Try Dim lbl As New Label Dim LblPos As Point LblPos.X = e.X LblPos.Y = e.Y lbl.Name = "TestLabel" lbl.Text = Labeltext lbl.Location = LblPos lbl.BackColor = Color.LightGray Me.Controls.Add(lbl) Catch ex As Exception End Try End Sub as you can see i have created label on the form design area on the Form mouse move event. i tried using Form1_DragDrop Event ...but it was not getting fired when i use to leave the mouse. I hope by now you must have got what i am looking for. Regards Ismail >Hi Sayed, > >Please refer to the following KB article for information on this : > >How do I perform the drag drop operation between an XPToolBar and TreeViewAdv ? > >Let me know if you need further assistance. > >Regards, >Guru Patwal >Syncfusion, Inc.


AD Administrator Syncfusion Team May 12, 2005 10:35 AM

Hi Ismail, Did you set AllowDrop to True on your Form? I wasn''t receiving DragDrop notification myself until I remembered to turn that on. Also, I''d recommend using the Form''s PointToClient method to convert LblPos to the Form relative coordinates you''re looking for. Regards, Gregory Austin Syncfusion Inc.


AD Administrator Syncfusion Team May 15, 2005 11:30 PM

hi Gregory Thank You. very much for the help. After setting the Allow Drop Property To TRUE, i got my task done...great.. Thanks Once again... ;)


SS Sharad Sharma July 1, 2005 01:50 AM

Hi Gregory, I am working on TreeViewAdv control and trying it''s ItemDrag event. The problem is that, if i try to use following statement to Text property of current node... (((TreeViewAdv)sender).SelectedNode).Parent.Text; Then it always gives following error... Why it is so. Please help me out from this issue. Thanks Takecare bye Sharad. >Hi Ismail, > > Did you set AllowDrop to True on your Form? I wasn''t receiving DragDrop notification myself until I remembered to turn that on. > > Also, I''d recommend using the Form''s PointToClient method to convert LblPos to the Form relative coordinates you''re looking for. > >Regards, >Gregory Austin >Syncfusion Inc.


AD Administrator Syncfusion Team July 5, 2005 05:05 PM

Hi Sharad, What error do you get? I don''t see it anywhere in your post. Regards, Gregory Austin Syncfusion Inc.

Loader.
Live Chat Icon For mobile
Up arrow icon