Menu.MenuItemCollection.Item[String] Property

Definition

Gets an item from the collection.

Overloads

Item[Int32]

Retrieves the MenuItem at the specified indexed location in the collection.

Item[String]

Gets an item with the specified key from the collection.

Item[Int32]

Retrieves the MenuItem at the specified indexed location in the collection.

public:
 virtual property System::Windows::Forms::MenuItem ^ default[int] { System::Windows::Forms::MenuItem ^ get(int index); };
public virtual System.Windows.Forms.MenuItem this[int index] { get; }
member this.Item(int) : System.Windows.Forms.MenuItem
Default Public Overridable ReadOnly Property Item(index As Integer) As MenuItem

Parameters

index
Int32

The indexed location of the MenuItem in the collection.

Property Value

The MenuItem at the specified location.

Exceptions

The value parameter is null.

or

The index parameter is less than zero.

or

The index parameter is greater than the number of menu items in the collection, and the collection of menu items is not null.

Remarks

To assign MenuItem objects to a specific location, or to retrieve them from the Menu.MenuItemCollection, you can reference the collection object with a specific index value. The index value of the Menu.MenuItemCollection is a zero-based index.

See also

Item[String]

Gets an item with the specified key from the collection.

public:
 virtual property System::Windows::Forms::MenuItem ^ default[System::String ^] { System::Windows::Forms::MenuItem ^ get(System::String ^ key); };
public virtual System.Windows.Forms.MenuItem this[string key] { get; }
member this.Item(string) : System.Windows.Forms.MenuItem
Default Public Overridable ReadOnly Property Item(key As String) As MenuItem

Parameters

key
String

The name of the item to retrieve from the collection.

Property Value

The MenuItem with the specified key.

Remarks

The Name property corresponds to the key for a MenuItem in the Menu.MenuItemCollection.

The key comparison is not case-sensitive. If the key parameter is null or an empty string, Item[String] returns null.

Applies to