Bar
A newer version of this page is available. Switch to the current version.

BarEditItem Class

Represents a bar item containing an editor from the DevExpress Editors Library.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v18.2.dll

Declaration

public class BarEditItem :
    BarItem
Public Class BarEditItem
    Inherits BarItem

Related API Members

The following members accept/return BarEditItem objects:

Library Related API Members
WinForms Controls BarEditItemLink.Item
Reporting XRDesignBarManager.FontNameEdit
XRDesignBarManager.FontSizeEdit

Remarks

This class combines the functionality of a bar item and a specific editor. BarEditItem allows any editor provided by the XtraEditors library or any custom editor that expands the standard editors to be displayed. The following image shows a bar containing three bar edit items:

Bars3_BarEditItem

When you place a bar edit item onto a bar or menu, a BarEditItemLink object is created to represent this item.

To assign an editor for the bar edit item, use the BarEditItem.Edit property. This property specifies a repository item, which defines the editor type and multiple edit settings. The XtraEditors library provides repository items for each editor it contains.

Note that the repository item you wish to use for the bar edit item, should be added to the BarManager's internal repository (ComponentEditorContainer.RepositoryItems) or external repository (ComponentEditorContainer.ExternalRepository).

To access the edit value, use the BarEditItem.EditValue property. For instance, you can use this property to specify an initial value for the editor.

An item's editor can be prevented from being focused via the BarEditItem.CanOpenEdit property. This can be useful, for instance, for ProgressBarControl controls which do not have editing capabilities.

Note that if a bar's BarOptions.RotateWhenVertical property is true, editors of BarEditItemLink links are not displayed if a bar is vertically docked.

Edit links can be represented within vertically oriented bars only using captions and/or glyphs. You can perform specific actions when the end-user clicks on these captions or glyphs by handling the BarItem.ItemClick or BarManager.ItemClick event (you can for instance, invoke a dialog that provides customization facilities, etc).

To make edit links visible within vertically docked bars, set the items' BarEditItem.VisibleWhenVertical property to true and then do one of the following things:

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.

NOTE

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.

Examples

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.

BarEditItem-EditValue-example.png

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");
    bar1.AddItem(item);
    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