I have two grids on a form. I have set the same right-click context menu on both grids (ultraToolbarsManager.SetContextMenuUltra) using a wintoolbar. How can I determine the underlying source control (i.e. either grid1 or grid2).
I will performing something similar on many forms, so I do not want to have to code in a MouseDown event on all the grids. I really want a way to determine this dynamically. Thanks for any ideas.
Hello Bob,
When the UltraToolbarsManager displays a context menu (PopupMenu), it will fire the BeforeToolDropDown event. The eventargs for this event will expose the Tool being displayed and the SourceControl which is the control for which the context menu is being shown. In your case, the Source control should return the grid being clicked on.
Let me know if you have any further questions. Thanks,
Chris
The e.SourceControl value in my case returns a value of "Nothing". The form inherits from a baseform. The ToolBarManager is on the baseform. This could be why it is returning "Nothing"?
I appreciate any other ideas as a work around? Thanks.
There must be something else interfering with the ability to return the SourceControl. I've tested the scenario where the UltraToolbarsManager is on a base form, and it still returns the SourceControl as expected. I've attached the sample so you can see exactly what I did. It is written in VB.NET as I assumed that was the language you are using based on your use of "Nothing". Test my attached sample, and verify it is working correcting on your system. If it does, see if there are any other differences between how your application is set up and the test application.
Thanks,
You are correct on both points. Yes, I did something that was interfering with the result.
I had changed the Me.UltraToolbarsManager1.SetContextMenuUltra(Me.UltraGrid1, "PopupMenuTool1") to a Me.UltraToolbarsManager1.ShowPopup("PopupMenuTool1", Me.UltraGrid1) on the UltraGrid1 MouseDown event as an alternative method. Unfortunately, I left that code in place when I tried your BeforeToolDropDown event frmo the ToolsBarManager.
This works perfectly for my needs. Thanks.