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

BarItemLink Class

Specifies a bar element.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v19.2.dll

Declaration

The following members return BarItemLink objects:

Remarks

Bar items (BarItem objects) are bar buttons, menu commands, static captions, and other elements that can be placed in a toolbar, menu, or ribbon. A single bar item can be placed in a toolbar and menu at the same time. This allows users to invoke commands in any convenient way.

For this purpose, the BarManager creates item links (BarItemLink objects) based on bar items. An item link represents the corresponding bar item in a toolbar, menu, or ribbon. You can use link properties to customize the bar item in the toolbar and menu differently (for example, you can specify a short caption in the toolbar and a detailed caption in the menu).

For performance reasons, item links are not created until the form is loaded. That is why changing link properties is not in effect until the BarManager is loaded. If you specify a link property in code before the BarManager is loaded (for example, in the form’s constructor), call the BarManager.ForceLinkCreate or BarManager.ForceInitialize method first.

using DevExpress.XtraBars;

public Form1() {
    InitializeComponent();
    bm.ForceInitialize();
    BarButtonItem bbiNew = new BarButtonItem(bm, "New");
    bbiNew.ImageUri.Uri = "New";
    BarItemLink link1 = bar1.AddItem(bbiNew);
    // The BeginGroup property is not in effect until the BarManager component is initialized.
    link1.BeginGroup = true;
}

You can also specify link properties in the Form.Load event that fires when the BarManager is already loaded.

this.Load += Form1_Load;

private void Form1_Load(object sender, EventArgs e) {
    BarButtonItem bbiNew = new BarButtonItem(bm, "New");
    bbiNew.ImageUri.Uri = "New";
    BarItemLink link1 = bar1.AddItem(bbiNew);
    // The BeginGroup property is not in effect until the BarManager component is initialized.
    link1.BeginGroup = true;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BarItemLink class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also