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
225
UltraTab context menus
posted

Hi,

I want to beable to right-click on a tab and pop-up a context menu to rename/remove the tab etc.

The built in context menu does't know what tab I have right clicked on? atleast I don't think it does, and it pops up over the shared window which has its own context menu. So I thought I would do it myself with the mouse down event, I have checked for right click only and then call ElementFromPoint() which gets me the UIElement of the tab I clicked.

I can't work out how to tell if its a tab element or how to convert that to an UltraTab object?

 

Cheers,

Dave

  • 44743
    posted

    You have to be careful, because the element returned from ElementFromPoint may be a sub element within the tab element, so you must first get to the tab element, then you can try to access the tab:

    TabItemUIElement tabElement = (TabItemUIElement)elementAtPoint.GetAncestor(typeof(TabItemUIElement));

    if(tabElement != null)

    {

      UltraTab tab = (UltraTab)tabElement.TabItem;

      // Initialize context menu for this tab

    }

    However, you do not need to get involved with the elements if you don't want to. You can just use the TabFromPoint method on the UltraTabControl.