IInitializeContextMenu event for UltraTabbedMdiManager is documented for net 4 version in Infragistics help:
InitializeContextMenu Event - Infragistics Windows Forms HelpBut the API for net 7 version is different. Instead of Infragistics-specific IGMenuItem controls standard ToolStripItem classes are used. And when I try to use them I get working menu items but without text or images. Basically empty lines in a menu.Before I blame Infragistics for this it would be nice to look at some "official" net 7 example. Could be I'm doing something wrong. Is there such an example somewhere?
Hello,
Thank you for contacting Infragistics. Please attach a complete sample demonstrating the issue.
HelloActually it was I who was asking for a working sample :-) Because looks like the standard documentation doesn't have it. It is about net 4. But net 7 version will be more and more requested.This is not (yet) an issue report, because could be I'm doing something wrong (need an example).Providing the whole sample from me would be difficult because it is a complex commercial software requiring a server part to be running.But the task is pretty simple. I have UltraTabbedMdiManager there and in addition to the standard context menu I'd like to insert a couple of convenience menu items: "Close All" and "Close All but this". This worked in net 4 version.Here how it looks in net 7:
private void m_UltraTabbedMdiManager_InitializeContextMenu( object sender, MdiTabContextMenuEventArgs e ) { if ( e.ContextMenuType != MdiTabContextMenu.Default ) return; // Find the position of the 'Close' menu item int idxClose = -1; for ( int i = 0; i < e.ContextMenu.Items.Count; i++ ) { if ( StringComparer.OrdinalIgnoreCase.Compare( e.ContextMenu.Items[i].Text, m_ResourceService.GetString( ResourceIds.Presentation_WinForms_Close ) ) == 0 ) { idxClose = i; break; } } if ( idxClose == -1 ) return; ToolStripItem menuItemCloseAllButThis = new ToolStripButton( "Close all but this" ); menuItemCloseAllButThis.Click += ( sndr, eargs ) => { MdiTab mdiTabNotToClose = ( sndr as ToolStripItem ).Tag as MdiTab; foreach ( MdiTab mdiTab in GetAllMdiTabs( m_UltraTabbedMdiManager ) ) { if ( mdiTab != mdiTabNotToClose ) mdiTab.Close(); } } ); menuItemCloseAllButThis.Tag = e.Tab; ToolStripItem menuItemCloseAll = new ToolStripButton( "Close all" ); menuItemCloseAll.Click += ( sndr, eargs ) => { foreach ( MdiTab mdiTab in GetAllMdiTabs( m_UltraTabbedMdiManager ) ) mdiTab.Close(); } ); e.ContextMenu.Items.Insert( idxClose + 1, menuItemCloseAll ); e.ContextMenu.Items.Insert( idxClose + 1, new ToolStripSeparator() ); e.ContextMenu.Items.Insert( idxClose + 1, menuItemCloseAllButThis ); e.ContextMenu.Opening += ( sndr, eargs ) => { ContextMenuStrip contextMenu = sndr as ContextMenuStrip; if ( contextMenu.Items.Count > idxClose + 1 ) { contextMenu.Items[idxClose + 1].Enabled = GetAllMdiTabs( m_UltraTabbedMdiManager ).Count > 1; } }; }
The difference with net 4 version is that I insert ToolStripButton instead of IGMenuItem.And here is the menu I get:
Note that a tooltip is correct, but no menu text is shown, the menu item is just empty.
Your welcome, have a nice day!
Replacing ToolStripButton with ToolStripMenuItem solved the issue, thanks!
Hello and thank you for following up.
e.ContextMenu.MenuItems was replaced with e.ContextMenu.Items
Menu.MenuItemCollection was deprecated by Microsoft and replaced with ToolStripItemCollection
See
https://learn.microsoft.com/en-us/dotnet/core/compatibility/3.1
eg.
ToolStripMenuItem t1 = new ToolStripMenuItem("New Item"); ToolStripMenuItem t2 = new ToolStripMenuItem("New Item 2");
// Adds the menu items to the context menu e.ContextMenu.Items.Add(t1); e.ContextMenu.Items.Add(t2);
From what I can see ToolStripButton in the context menu isn't possible and considered to be a new product idea.
You can suggest new product ideas for future versions (or vote for existing ones) at <www.infragistics.com/.../ideas>. Submitting your idea will allow you to communicate directly with our product management team, track the progress of your idea at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you. Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it.
Let me know if you have any questions.