ComponentOne Menus and Toolbars for WinForms
Menus and Toolbars Overview / Menus and Toolbars Functionality
In This Topic
    Menus and Toolbars Functionality
    In This Topic

    The functionality of a menu item and a toolbar button is very similar in C1Command. The menu item or toolbar button is split between two components: a command and a command link.

    Functionality of a C1Command Component

    The command (an object of type C1Command or derived types, see Class Hierarchy for a list) is used to hold properties and event handlers related to the actual action which the command represents. Commands themselves are not contained in C1Commands menus and toolbars. Instead, all commands on a form are stored as a single collection in a component of type C1CommandHolder, a single instance of which is automatically created on the form when you add the first C1Commands menu or toolbar to it.

    For more information on how to use C1CommandHolder, please see C1CommandHolder Component. To represent commands in menus and toolbars, command links (components of type C1CommandLink) are used.

    Functionality of a C1CommandLink Component

    A command link is a small and quite simple component. Its most important property is Command, which points to the actual command object associated with this command link. Aside from this, a command link allows you to override some of the properties of the linked command, such as text. The visual representation of a command link depends on two factors: the command it links to and whether the link is contained in a main menu, a popup menu, or a toolbar.

    Properties used to show the command link are taken from the command, for example text or image, whereas the way they are shown is determined by the container. In a main menu, only the command’s text is shown and in a popup menu the image and the shortcut are also shown, and so on. Multiple command links can point to the same command, which is one of the main reasons why commands and command links are separate items.

    Relationships Among Commands, Command Links, Menus and Toolbars, and Command Holder

    To sum it up, the following relationships exist between commands, command links, menus and toolbars, and the command holder on a form:

    See Also