Skip to main content
Bar

BarDockControl.Controls Property

Gets the collection of bars displayed within the bar dock control.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[Browsable(false)]
public Control.ControlCollection Controls { get; }

Property Value

Type Description
Control.ControlCollection

The collection of bars displayed within the bar dock control.

Remarks

Use the BarDockControl.Controls property to access bars that are displayed within the bar dock control.

The BarDockControl.Controls property stores a collection of DevExpress.XtraBars.Controls.DockedBarControl objects that refer to bars (DockedBarControl.Bar).

The following example iterates through all bar item links displayed in toolbars and disables bar item links that correspond to ‘save’ commands:

Disable Item Links Based on a Condition - WinForms Bars, DevExpress

using DevExpress.XtraBars;
using DevExpress.XtraBars.Controls;
using DevExpress.XtraEditors;
using System;

namespace DXApplication
{
    public partial class Form1 : XtraForm
    {
        public Form1()
        {
            InitializeComponent();
            barManager1.ForceInitialize();
        }
        void Form1_Load(object sender, EventArgs e)
        {
            foreach(BarDockControl dockControl in barManager1.DockControls)
                foreach(DockedBarControl dockContainer in dockControl.Controls)
                    foreach(BarItemLink link in dockContainer.Bar.ItemLinks) {
                        if (link.Caption.ToLower().Contains("save"))
                            link.Item.Enabled = false;
                    }
        }
    }
}
See Also