property PopupMenu.Command (ID as Long) as Command

Retrieves a Command object based on menu item identifier.

 TypeDescription 
   ID as Long A long expression that indicates the command's identifier.  
   Command A Command object that points to an menu item.  

Use the Command property to get information about the selected item. 

The following sample displays the caption of the selected item:

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 2) Then
        Dim nID As Long
        nID = PopupMenu1.ShowAtCursor
        If (nID > 0) Then
            MsgBox "You have selected the '" & PopupMenu1.Command(nID).Caption & "'"
        End If
    End If
End Sub

Send comments on this topic.
1999-2016 Exontrol.COM, Software. All rights reserved.