Table of Contents

Class FormMenuItem

Namespace
RDCore.Forms.Menus
Assembly
RDCore.Forms.dll

A menu item of a form: a VB.Menu component, with VB's members and the rules VB6 has for them.

public sealed class FormMenuItem
Inheritance
FormMenuItem
Inherited Members

Remarks

An item that holds items is a menu: choosing it opens its menu. An item whose Caption is a hyphen is a separator, drawn as a line.

The setters refuse what VB6 refuses, as measured with VB6: Checked on a top-level item or a separator, a separator's Enabled set to False, the last visible item of a menu hidden, and a hyphen as a caption.

Properties

Array

The menu array the item is an element of, or null for an item that is not an element of one, or that is unloaded.

public FormMenuArray? Array { get; }

Property Value

FormMenuArray

Caption

The item's text. An ampersand marks the character after it as its access key, and two ampersands show one.

public string Caption { get; set; }

Property Value

string

Exceptions

FormErrorException

Set to a hyphen on an item that is not a separator: 395, Cannot use separator bar as menu name for this control.

CheckOnClick

Whether choosing the item ticks or unticks it before its Click: an RD-VBA addition. False, the default, leaves Checked to the program, as a VB6 menu does.

public bool CheckOnClick { get; set; }

Property Value

bool

Checked

Whether the item shows a check mark.

public bool Checked { get; set; }

Property Value

bool

Exceptions

FormErrorException

Set on a top-level item or a separator: 387, 'Checked' property can't be set on this control.

Component

The menu component.

public ComponentInstance Component { get; }

Property Value

ComponentInstance

Enabled

Whether the item can be chosen, and its menu opened. A disabled item is drawn greyed.

public bool Enabled { get; set; }

Property Value

bool

Exceptions

FormErrorException

Set to False on a separator: 387, 'Enabled' property can't be set on this control.

HelpContextID

The context number of the item's help topic. A program reads and sets it.

public int HelpContextID { get; set; }

Property Value

int

Index

The item's index in its menu array, or null for an item that is not an element of one.

public int? Index { get; }

Property Value

int?

IsSeparator

Whether the item is a separator: its Caption is a hyphen.

public bool IsSeparator { get; }

Property Value

bool

IsTopLevel

Whether the item is on the menu bar.

public bool IsTopLevel { get; }

Property Value

bool

Items

The items of the item's menu, in the order it holds them: none for an item that opens no menu.

public IReadOnlyList<FormMenuItem> Items { get; }

Property Value

IReadOnlyList<FormMenuItem>

Parent

The menu that holds the item, or null for an item of the menu bar.

public FormMenuItem? Parent { get; }

Property Value

FormMenuItem

Picture

The picture shown beside the item's caption, as the bytes of its image file, or null for none: an RD-VBA addition.

public byte[]? Picture { get; set; }

Property Value

byte[]

Shortcut

The key that chooses the item from anywhere on its form, or null for none.

public MenuShortcut? Shortcut { get; set; }

Property Value

MenuShortcut?

Visible

Whether the item is shown. A hidden item takes no space and no shortcut, and the items of its menu are hidden with it.

public bool Visible { get; set; }

Property Value

bool

Exceptions

FormErrorException

Set to False on the last visible item of a menu, a separator included: 387, 'Visible' property can't be set on this control. The last visible item of the menu bar can be hidden, and the bar goes with it.

Methods

Load()

Loads the item, as a program's Load statement does with it.

public void Load()

Exceptions

FormErrorException

Always. An element of a menu array is loaded already: 360, Object already loaded; one that is unloaded is not one of the array's: 340. An item that is not an element of an array cannot be loaded: 361, Can't load or unload this object. A program loads an element with Load(int).

Of(ComponentInstance)

Gets the item a menu component is.

public static FormMenuItem Of(ComponentInstance menu)

Parameters

menu ComponentInstance

The menu component.

Returns

FormMenuItem

The item: the same object each time for the same component.

Exceptions

ArgumentNullException

menu is null.

ArgumentException

menu is not a Menu.

Unload()

Unloads the item, as a program's Unload statement does with it: Unload(int) for an element of a menu array.

public void Unload()

Exceptions

FormErrorException

The item is not an element of an array: 361, Can't load or unload this object. It is unloaded already: 340. Otherwise as Unload(int).