Toolstripitem always at the end of menu

552 views Asked by At

Does anyone know any way of keeping an toolstripitem always at the end of the menu ? regardless of adding or removing other items.

thanks, Horea

1

There are 1 answers

0
KeithS On

If you're adding menu items dynamically, try using AddAt() instead of Add() in the MenuItemCollection of the ToolStrip. Add each new menu item to the index two less than the size of the collection, and that'll keep the current last MenuItem last.

In the designer, you don't have anything to keep something to the outside of anything new you create, but you can just drag and drop to get them in the (initial) order you want.

You can also use various Layout properties. If you're merging two menus together, you can specify the MergeAction to be Insert, with a MergeIndex indicating where you'd like new ones to go. You can use the Alignment property of a ToolStripMenuItem located directly in a ToolStrip to put a root menu or menu item on the right side of the menu bar or toolstrip.