Bar

BarManager.ForceLinkCreate() Method

Forces the manager to create item links based on bar items.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v20.1.dll

Declaration

public virtual void ForceLinkCreate()
Public Overridable Sub ForceLinkCreate

Remarks

Bar items 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 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 ForceLinkCreate() method fires the Load event.

See Also