This documentation is archived and is not being maintained.

MenuItem.Index Property

Gets or sets a value indicating the position of the menu item in its parent menu.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public int Index { get; set; }

Property Value

Type: System.Int32
The zero-based index representing the position of the menu item in its parent menu.


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.

 public void SwitchMyMenuItems()
    // Move menuItem1 down one position in the menu order.
    menuItem1.Index = menuItem1.Index + 1;
    // Move menuItem2 up one position in the menu order.
    menuItem2.Index = menuItem2.Index - 1;

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.