MenuItem::Index Property
Gets or sets a value indicating the position of the menu item in its parent menu.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: [BrowsableAttribute(false)] property int Index { int get(); void set(int value); }
Property Value
Type: System::Int32The zero-based index representing the position of the menu item in its parent menu.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The assigned value is less than zero or greater than the item count. |
This property provides the indexed position of a menu item in the menu item collection of its parent menu. You can use this property to reposition a menu item to a different location within its menu. You can also use this property when creating a MenuItem to specify its position in a menu structure at the time of creation.
The following code example switches the position of two menu items in a menu. The following code example requires that two MenuItem objects are created named menuItem1 and menuItem2. The menuItem1 menu item moves down one position in the menu, while menuItem2 moves up one position.
Available since 1.1