I've created a PopupMenuTool with some attached buttons on a ribbon bar. I want to be able to drag & drop items onto said buttons. However, having picked up the drag event on the PopupMenuTool and called DropDown to open it successfully, I can't seem to find how to then get a drag/drop/mouseover/anything event on the buttons. Is this possible?
You can try to use the MouseEnterElement event on the toolbars manager and get the context of the entered element to see if it was a tool:
ToolBase enteredTool = (ToolBase)e.Element.GetContext( typeof( ToolBase ), false );
if ( enteredTool != null ){ // ...}
However, this will not work if you are dragging from a control which takes capture of the mouse when the mouse button is down. If that is the case, you would need to find the tool under the mouse in the mouse move of the control dragged from:
private void button1_MouseMove( object sender, MouseEventArgs e ){ Point screenLocationOfMouse = this.button1.PointToScreen( e.Location ); ToolBase toolUnderMouse = this.ultraToolbarsManager1.ToolFromPoint( screenLocationOfMouse );
if ( toolUnderMouse != null ) { // ... }}
Yes, the latter is true but the design is such that the candidate dropdown buttons are only some amongst several other possible drop targets, which otherwise work using DoDragDrop & the dragenter event. In the absence of a similar event for dropdown buttons on a ribbon bar, it's difficult to see how this can work. Is there really no other work-around, or could this be implemented?
Unfortunately, the component does not support drag and drop and I don't see a good way for a workaround. I would recommend submitting a feature request to the support group for this: http://devcenter.infragistics.com/Protected/RequestFeature.aspx.
I'm using a ribbon rather than a toolbar. This method desn't seem to work as I am unable to get the dock area events to fire.
Any suggestions?
Thanks,
JL
I've been tinkering with drag and drop for a bit now with the infragistics controls and I've written a bit of code to give me the functionality I would need. I realize this is an old post but just in case some else finds the code useful here it is.
in the constructor just after initialize component wire up your dragdrop, dragenter and dragover events for your dock area eg.
_TabControl_Toolbars_Dock_Area_Bottom.DragEnter += new DragEventHandler(buttonTrash_DragEnter);
_TabControl_Toolbars_Dock_Area_Bottom.DragOver += new DragEventHandler(buttonTrash_DragOver);
in each event use the following code:
if (ultraToolbarsManager1.Toolbars[0].Tools["buttonTrash"].Bounds.Contains(pt))
{
e.Effect = DragDropEffects.All;
// Implement your code here
// eg.
e.Data.SetData(new object());
}
else