Items and Links
- 3 minutes to read
#Bar Items
To add elements (buttons, sub-menus, static text, editors, etc) to bars and menus, you need to create appropriate bar items. A bar item is a non-visual object that implements a specific functionality. An item defines how a corresponding element appears onscreen, and determines the element's response to mouse clicks.
Bar items are BarItem class descendants. A typical bar item is a button, represented by the BarButtonItem class. Clicking this item fires the BarItem.ItemClick and BarManager.ItemClick events, and also invokes the command assigned to the BarItem.Command property. Other bar item types are described in the The List of Bar Items and Links topic.
Created items must be added to the BarManager.Items collection.
To logically organize items, you usually divide them into categories, which help an end-user to locate items at runtime via the Customization Window.
#Bar Item Links
After bar items have been created, you need to add them to bars and/or menus. This is performed by adding the item to the bar's/menu's ItemLinks collection. When a bar item is added to this collection, a bar item link is created and added to the collection instead of the item. A bar item link is an object that refers to a corresponding bar item. It defines the look of an item, while all the functionality is defined by the item. You can create multiple links for an item, but all of them will invoke the same functionality when clicked. For instance, you can create an "OpenFile" item that invokes the Open file dialog. Then, you can add a link to this item within the main menu and a toolbar, for instance.
Bar items provide settings to control the default look of its bar item links. They have properties to specify the default caption, glyph, editor width (for edit items), etc. However, you can override these settings for each link.
To access all bar item links for a bar item, use the BarItem.Links property.
#Examples
- How to create bar items and associate them with categories
- How to embed in-place editors into bars
- How to get and focus an in-place editor
- How to create various bar items and add separators between links
- How to create a BarLinkContainerItem
- How to create a BarSplitButtonItem
- How to create a BarToolbarItemList item
- How to create BarStaticItem items
- How to create a bar containing an embedded text editor