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
close icon

Drag & Drop from TreeViewAdv to XPToolbar

Hi All, I am currently attempting to do the above. Does anyone have any experience attempting this? It seems as though the DragOver and DragDrop events on my XPToolbar aren''t firing, however the DragEnter event does fire. Any information/advice would be greatly appreciated. Sincerely, Jon

1 Reply

AD Administrator Syncfusion Team March 10, 2005 07:53 PM UTC

Hi Jon, The XPToolBar’s DragDrop event does not get fired as expected (defect# 93) and this seems to be a shortcoming in our XPToolBar control. To workaround this issue, derive from our XPToolBar to create a CustomXPToolBar control (and a CustomDragDrop event handler) as shown below : public class CustomXPToolBar : XPToolBar { public CustomXPToolBar () : base() {} public event DragEventHandler CustomDragDrop; protected override void OnDragDrop(System.Windows.Forms.DragEventArgs e) { if(this.CustomDragDrop != null) this.CustomDragDrop(this, e); } } Now handle the XPToolBar’s DragEnter, CustomDragDrop events and TreeViewAdv’s MouseDown events as shown below : private void xpToolBar1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { Console.WriteLine ("XPToolBar Drag Enter"); if (e.Data.GetDataPresent(typeof(TreeNodeAdv))) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } private void xpToolBar1_CustomDragDrop(object sender, System.Windows.Forms.DragEventArgs e) { Console.WriteLine ("XPToolBar Drag Drop"); if (e.Data.GetDataPresent(typeof(TreeNodeAdv))) { TreeNodeAdv node = e.Data.GetData(typeof(TreeNodeAdv)) as TreeNodeAdv; BarItem bitem = new BarItem(node.Text); this.xpToolBar1.Items.Add(bitem); } } private void treeViewAdv1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { // get the point where the mouse was left clicked Point p = this.treeViewAdv1.PointToClient(Control.MousePosition); // get the node at the left click point TreeNodeAdv node = this.treeViewAdv1.PointToNode(p); DoDragDrop(node, DragDropEffects.Copy); } } The complete sample illustrating the above is attached here. Please refer to it and let me know if you need further assistance. Regards, Guru Patwal Syncfusion, Inc.

Loader.
Live Chat Icon For mobile
Up arrow icon