Partilhar via


ContextMenu::Item property

The Item property returns the MenuItem object at a specified index or specified path. This property is read-only.

Syntax

Property Item( _
  ByVal IndexOrPath As Variant _
) As MenuItem

Property value

The MenuItem object at the position specified by IndexOrPath in the set of MenuItem objects maintained by this collection, or NULL if the item does not exist.

Examples

' Retrieve the item count of the ContextMenu object.
Dim nCount As Long
nCount = objCtxMenu.Count

Dim i As Long
Dim objMenuItem As MMC20.MenuItem
 
' Iterate the menu items using the index.
For i = 1 To nCount
    Set objMenuItem = objCtxMenu.Item(i)
    ' Use the MenuItem object. For example,
    ' display the name.
    MsgBox (objMenuItem.DisplayName)
    ' Free the object for the next iteration.
    Set objMenuItem = Nothing
Next i

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
MMCObj.h
IDL
MMCObj.idl
DLL
Mmcndmgr.dll
IID
IID_ContextMenu is defined as DAB39CE0-25E6-4E07-8362-BA9C95706545

See also

ContextMenu.Count

MenuItem object