I have an UltraTab that gets only a UltarWinGrid or a RichTextBox loaded into the tab depending on what the application needs at runtime. If a grid gets loaded into the tab, I want to assign a 2 item menu to the tab. I know you can assign a menu to the TabControl but I want the menu assigned to specifc tabs only so the user can right click that tab and perform these two operations...
Steve Graddy
Hi Mike,
Thanks for the quick reply. This was the exact answer that I was looking for. This works perfect. Infragistics as always was on top of their game. This was very much appreciated.
To do this, you would need to handle the MouseDown event of the tab control and assign or remove your context menu depending on where the right mouse down has occurred. You can determine the element the mouse is over by using the location of the event args:
UIElement element = this.ultraTabControl.UIElement.ElementFromPoint(e.Location);
If the returned element is not null, you get determine if the element is an tab element, or is within a tab element like this:
TabItemUIElement tabItemElement = (TabItemUIElement)element.GetAncestor( typeof( TabItemUIElement ) );
If the tabItemElement is not null, you get the tab associated with the element like this:
UltraTab tab = (UltraTab)tabItemElement.TabItem;
If you want to show the context menu for that tab, assign the context menu to the tab control. Otherwise, remove the context menu from the tab control.