2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Perform the node drag drop between XPToolBar and TreeViewAdvPlease refer the following steps to be performed to achieve this: 1. Place the TreeViewAdv and XPToolBar on the form. 2. Add nodes to the TreeViewAdv. 3. Set the AllowDrop property as True of the XPToolBar. 4. Handle the TreeViewAdv MouseDown event to access the node which is going to drag. 5. Handle the DragDrop and DragEnter events of XPToolBar to get the which is dragged from the TreeViewAdv. Please refer the below code snippet which ilustrates this: C# 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_DragDrop(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); this.treeViewAdv1.SelectedNode = node; this.treeViewAdv1.Refresh(); DoDragDrop(node, DragDropEffects.Copy); } } VB Private Sub XpToolBar1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles XpToolBar1.DragDrop Console.WriteLine("XPToolBar Drag Drop") If e.Data.GetDataPresent(GetType(TreeNodeAdv)) Then Dim node As TreeNodeAdv = CType(IIf(TypeOf e.Data.GetData(GetType(TreeNodeAdv)) Is TreeNodeAdv, e.Data.GetData(GetType(TreeNodeAdv)), Nothing), TreeNodeAdv) Dim bitem As BarItem = New BarItem(node.Text) Me.XpToolBar1.Items.Add(bitem) End If End Sub Private Sub XpToolBar1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles XpToolBar1.DragEnter Console.WriteLine("XPToolBar Drag Enter") If e.Data.GetDataPresent(GetType(TreeNodeAdv)) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub Private Sub TreeViewAdv1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeViewAdv1.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then ' get the point where the mouse was left clicked Dim p As Point = Me.TreeViewAdv1.PointToClient(Control.MousePosition) ' get the node at the left click point Dim node As TreeNodeAdv = Me.TreeViewAdv1.PointToNode(p) Me.TreeViewAdv1.SelectedNode = node Me.TreeViewAdv1.Refresh() DoDragDrop(node, DragDropEffects.Copy) End If End Sub Sample: http://help.syncfusion.com/support/samples/KB/Tools.Windows/TDragDrop/DragDrop.zip |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.