Skip to main content
A newer version of this page is available. .

What are Bar Items and Bar Item Links?

  • 3 minutes to read

If you look at a Ribbon Page Group, status bar or Quick Access Toolbar you may see various visual elements (command buttons, static text, editors, menus, galleries, etc), each of which provides specific functionality.

CD_Ribbon_BarItems

If you need to add a command button, editor, static text or any other element to a bar, status bar, menu or Ribbon Control you need to create a specific bar item. Bar items provide multiple display and behavior options that can be customized: the caption, large and small images, events that occur when the corresponding elements are clicked, etc. For instance, to add a regular button to a bar you need to create a BarButtonItem object. Its Caption and Glyph properties allow you to assign text and image to the button. The item’s ItemClick event allows you to implement the button’s functionality. Note, however, that bar items are non-visual components.

All the visual elements (command buttons, editors, submenus, static text, etc) displayed within bars and the Ribbon Control are bar item links. A bar item link refers to a specific bar item, so it has all the necessary information to draw itself onscreen. In XtraBars, you can create multiple links to the same bar item and display them in different places. For instance, you can display links that refer to the same BarButtonItem on the Quick Access Toolbar and on a RibbonPage at the same time. Clicking on either of them will invoke the same event handler which is assigned to the BarButtonItem’s ItemClick event.

The DevExpress Ribbon, Menu and Docking Library provides multiple bar items that can be used to add various elements to the RibbonControl. For instance, a BarButtonItem object allows you to add a button, while a BarSubItem object is used to add a submenu, etc. For a complete list of bar items, see The List of Bar Items and Links.

Generally, there is no need to create bar item links manually. Instead, you need to create a specific bar item and add it to a Ribbon Page or bar. When a bar item is added to a Ribbon Page or bar, a link to this item is automatically created and added to the Ribbon Page/bar.

Note

If you create Bar Items in code, note that these objects may not function properly without being associated with a BarManager or RibbonControl. To create a Bar Item, use a Bar Item constructor that has the BarManager parameter. When creating a Bar Item in code for use within a RibbonControl, use a Bar Item constructor that has the BarManager parameter, and pass the RibbonControl.Manager object as this parameter.