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.
Unfortunately, activation email could not send to your email. Please try again.

How to drag and drop baritems from a XPToolBar to another XPToolBar?

 

It is possible to drag and drop bar items from a XPToolBar to another XPToolBar using DragDrop and DragEnter events.

C#

private void xpToolBar2_DragEnter(object sender, DragEventArgs e)

{

Console.WriteLine("XPToolBar Drag Enter");

if (e.Data.GetDataPresent(typeof(BarItem)))

e.Effect = DragDropEffects.Copy;

else

e.Effect = DragDropEffects.None;

}

private void xpToolBar2_DragDrop(object sender, DragEventArgs e)

{

Console.WriteLine("XPToolBar Drag Drop");

if (e.Data.GetDataPresent(typeof(BarItem)))

{

BarItem bitem = e.Data.GetData(typeof(BarItem)) as BarItem;

this.xpToolBar2.Items.Add(bitem);

}

}

private void XPToolBar_BarControlInternal_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

BarControlInternal bcint = sender as BarControlInternal;

Point pt = bcint.PointToScreen(new Point (e.X,e.Y));

BarItem bitem = bcint.HitTest(pt.X, pt.Y) as BarItem;

DoDragDrop(bitem, DragDropEffects.Copy);

}

}

VB

Private Sub xpToolBar2_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles xpToolBar2.DragEnter

Console.WriteLine("XPToolBar Drag Enter")

If e.Data.GetDataPresent(GetType(BarItem)) Then

e.Effect = DragDropEffects.Copy

Else

e.Effect = DragDropEffects.None

End If

End Sub

Private Sub xpToolBar2_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles xpToolBar2.DragDrop

Console.WriteLine("XPToolBar Drag Drop")

If e.Data.GetDataPresent(GetType(BarItem)) Then

Dim bitem As BarItem = TryCast(e.Data.GetData(GetType(BarItem)), BarItem)

Me.xpToolBar2.Items.Add(bitem)

End If

End Sub

Private Sub XPToolBar_BarControlInternal_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)

If e.Button = MouseButtons.Left Then

Dim bcint As BarControlInternal = TryCast(sender, BarControlInternal)

Dim pt As Point = bcint.PointToScreen(New Point (e.X,e.Y))

Dim bitem As BarItem = TryCast(bcint.HitTest(pt.X, pt.Y), BarItem)

DoDragDrop(bitem, DragDropEffects.Copy)

End If

End Sub

Sample:

http://help.syncfusion.com/support/samples/kb/tools.windows/kb_xptoolbardraganddrop/Tools_WF_KB_XPToolBarDragDrop.zip

Article ID: Published Date: Last Revised Date: Platform: Control:
1788 04/30/2011 07/10/2014 Windows Forms XPToolbar
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.