Skip to main content

BarEditItem Class

Represents a bar item that can contain an editor.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v22.1.dll

NuGet Package: DevExpress.Win.Navigation


public class BarEditItem :


The BarEditItem type allows you to display an editor in a bar.


To display an editor in a bar:

  • create an editor and an editor bar item,
  • wrap the editor in the editor bar item (use the BarEditItem.Edit property, or the corresponding constructor),
  • add the editor bar item to a bar.

Use the BarEditItem.EditValue property to specify the editor’s value. For instance, you can set an initial value.

using DevExpress.XtraBars;
using DevExpress.XtraEditors.Repository;

RepositoryItem editor = new RepositoryItemColorEdit();
BarEditItem barItem = new BarEditItem(barManager1, editor);
barItem.EditValue = Color.Red;


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.

Vertical bars

Bar items are rotated in vertical bars. Editors cannot be rotated, so editor bar items are automatically hidden. To display editor bar items in a vertical bar, you can do one of the following:

  • prevent bar items from being rotated - set the Bar.BarOptions.RotateWhenVertical property to false.

    bar1.OptionsBar.RotateWhenVertical = false;
  • display a glyph and/or caption only, without an editor - set the BarEditItem.VisibleWhenVertical property to true.

    Handle the BarItem.ItemClick or BarManager.ItemClick event to respond to clicks on editor bar items.

    bar1.OptionsBar.RotateWhenVertical = true;
    barItem.VisibleWhenVertical = true;
    barItem.ImageOptions.Image = Image.FromFile("colors.bmp");
    barItem.Caption = "Colors";
    barItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;
    barItem.ItemClick += BarItem_ItemClick;


An in-place editor (BaseEdit descendant) within a Bar, Menu or Ribbon Control is created from a RepositoryItem descendant and activated only when a corresponding edit box is focused. If the edit box is not focused, the editor doesn’t exist at this point in time. When the edit box loses focus, the corresponding editor is automatically destroyed. So, it’s not possible to access an editor displayed within a Bar/Menu/Ribbon Control unless this editor has focus.

To access and customize a specific in-place editor, first activate the editor via the BarEditItemLink.ShowEditor method. To access the editor, use the BarManager.ActiveEditor property (for the RibbonControl, use the RibbonControl.Manager.ActiveEditor property).

Specific dropdown editors allow their items to be populated from a data source (e.g., a LookUpEdit or CheckedComboBoxEdit). If this editor is embedded into a Bar or Ribbon Control and the corresponding edit box is not focused, changes made to the data source are not reflected by the edit box. To update the edit box, you can use the BarItem.Refresh method.


The following code shows how to:

  • embed a SpinEdit editor in a bar using the BarEditItem object.
  • assign an initial value to the editor (BarEditItem);
  • handle the BarEditItem.EditValueChanged event to perform actions when the editor’s value changes.


private void Form1_Load(object sender, EventArgs e) {
    // Create a BarEditItem with embedded SpinEdit in-place editor.
    BarEditItem item = new BarEditItem(barManager1);
    item.Edit = barManager1.RepositoryItems.Add("SpinEdit");
    item.EditValueChanged += BarEditItem1_EditValueChanged;

    // Specify the editor's initial value.
    int initialValue = 0;
    item.EditValue = initialValue;

// Perform actions when the editor's value changes
private void BarEditItem1_EditValueChanged(object sender, EventArgs e) {
    BarEditItem item = sender as BarEditItem;
    object newValue = item.EditValue;
See Also