Items
One top-level menu caption per line. A line containing '-' creates a separator; empty lines are ignored.
Connect menu items to a named event handler.
A menu belongs in the component tray even though it creates a visible command surface at runtime. Configure its items before writing the event code. Keep the command identity stable so renaming a visible label does not accidentally change what the application does.
Add Menu to the component tray and name it mnuMain for this example:
| Property | Example value |
|---|---|
Items | "File\nNew\n---\nQuit" |
Visible | True |
Enabled | True |
ClickedIndex | -1 |
A complete handler from Forms/frmMain.bas. The linked lesson includes its surrounding controls, declarations and helpers.
Private Sub mnuMain_Click()
lblStatus.Caption = "Menu item " & CStr(mnuMain.ClickedIndex + 1) & " selected."
End SubContract defaults are shown below. Where a new control has a different Designer starting value, that value is listed separately.
ItemsOne top-level menu caption per line. A line containing '-' creates a separator; empty lines are ignored.
VisibleWhether this menu is shown in the running application's menu bar.
EnabledWhether this menu accepts item interaction in the running application.
ClickedIndexZero-based index of the last clicked menu item; separators do not receive an index and -1 means no item has been clicked.
Range: -1 to 100000.
Replace control with the object’s Name when creating a handler. ByRef arguments may be changed by your handler; ByVal arguments report an input value.
Occurs once when the component is logically activated by the user.
Private Sub control_Click()No parameters.
No methods are declared in this component’s built-in metadata. Use its documented properties and events; do not infer APIs from a similarly named control in another framework.
20f4bfed6b · Build manifest