I can't believe ToolStripItem.MergeIndex is an absolute position…

I was working with some integration project where menus of the shell and a plugin are merged a-la MDI.
Both menus are ToolStrips. We used ToolStripManager.Merge() to merge them. It turns out that MergeIndex field of a source menu item is used as absolute position where this item will be inserted in the target menu. MergeIndexes of the target menu items are ignored.

E.g. if your source is (merge indexes in brackets)
PluginMenu[2]
and your target is
File View Help
then merged menu will be
File View PluginMenu Help.

If you later change the shell menu (target) to
File Edit View Window Help
then the merged menu will be
File Edit PluginMenu View Window Help

There is no way to specify something like “this plugin menu goes just before help” or “this plugin menu goes right after View”. Infragistics uses weights instead of absolute indexes. This creates much more sane and maintainable approach.

Leave a Reply

Your email address will not be published. Required fields are marked *