Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Problem dynamically adding a PopupMenuTool to an already existing PopupMenuTool
posted

I am having a problem adding a PopupMenuTool to an already existing PopupMenuTool. I am unable to post the code that I am using but I will try to explain.

I have an UltraWinGrid object (myWinGrid)

I have an UltraToolbarsManager object (mTBMgr).

I have a PopupMenuTool popMenu7 = new  PopupMenuTool ("gridPopup").

- the popMenu7 PopupMenuTool contains a bunch of buttons

popMenu7.Tools.AddRange ( ToolBase[] { buttonTool40, buttonTool41, .....});

- the popMenu7 PopupMenuTool is added to the UltraToolbarsManager object

mTBMgr.Tools.AddRange ( ToolBase[] { button50, popMenu7 , button 51,.....} );

(All of this is logic is in the InitializeComponent method of my form)

 

I have a event handler to handle the OnMouseUp event for the grid (myWinGrid). Here is the code for that event

 

protected void myWinGridOnMouseUp(sender, e)

{

 if (e.Button.Eqauls(MouseButton.Right)

{

PopupMenuTool contextMenu = mTBMgr.Tools["gridPopup"] as PopupMenuTool ;

PopupMenuTool newContext = new PopupMenuTool("Columns");

newContext.SharedProps.Caption = "Columns";

mTBMgr.Tools.Add(newContext );

contextMenu.Tools.AddTool("Columns");

contextMenu.ShowPopup();

}

}

When I run this code, the "Columns" popup menu is not displaying in the popMenu7 menu. If I step through the code and I examine the contents of the mTBMgr and popMenu7, the "Columns" popup menu exists in the Tools collection but it is not displaying.

We have 2 versions of Infragistics at our Company, version 8 (8.1.20081.1000) and version 10 (10.1.20101.1007). The code I have listed above works when I use version 8 of Infragistics but it does not work when I use version 10 of Infragistics.

 

 

 

 

Parents
No Data
Reply
  • 44743
    posted

    There is a proxy ContextMenuStrip that is trying to open when you right click on a control. Internally, the UltraToolbarsManager is detecting this and showing the popMenu7 instead. In older versions, this was a ContextMenu instead of a ContextMenuStrip. My guess is Microsoft changed the order of events with regard to the context menu opening and the MouseUp event. So when you add a tool to popMenu7 in the MouseUp event, it has already started displaying itself as a context menu.

    Regardless of event order, trying to do this is MouseUp event is not recommended, specifically because of the unpredictable order. It is better to handle the UltraToolbarsManager.BeforeToolDropdown event. If the tool being dropped down is a context menu, the SourceControl property of the event args will be the Control that was right-clicked and the Tool property will be a root tool.

Children