Target
Name of the visual control that receives this context menu. The target must be declared in the same form.
Attach a contextual menu to the intended target control.
The target relationship determines where the menu appears. Configure it in the component properties rather than drawing a fake menu into the Form. Handle the selected command in the ContextMenu event and leave the target’s normal interaction intact.
Add ContextMenu to the component tray and name it ctxTarget for this example:
| Property | Example value |
|---|---|
Target | "cmdTarget" |
Items | "Open\n---\nCopy" |
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 ctxTarget_Click()
lblStatus.Caption = "Context item " & CStr(ctxTarget.ClickedIndex + 1) & " selected."
End SubContract defaults are shown below. Where a new control has a different Designer starting value, that value is listed separately.
TargetName of the visual control that receives this context menu. The target must be declared in the same form.
ItemsOne context-menu caption per line. A line containing '-' creates a separator; empty lines are ignored.
VisibleWhether the context menu is available on its target control.
EnabledWhether the context menu accepts item interaction.
ClickedIndexZero-based index of the last clicked context-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