TabbedGroup.CustomHeaderButtons Property

Provides access to the collection of custom buttons displayed in the tabbed group header.

Namespace: DevExpress.XtraLayout

Assembly: DevExpress.XtraLayout.v20.2.dll

Declaration

[DXCategory("Behavior")]
public virtual CustomHeaderButtonCollection CustomHeaderButtons { get; }
<DXCategory("Behavior")>
Public Overridable ReadOnly Property CustomHeaderButtons As CustomHeaderButtonCollection

Property Value

Type Description
CustomHeaderButtonCollection

The CustomHeaderButtonCollection object that represents a collection of custom buttons displayed in the tabbed group header.

Remarks

The CustomHeaderButtons property allows you to add custom buttons to the tabbed group header. To perform actions on clicking custom header buttons, handle the TabbedGroup.CustomHeaderButtonClick event.

In the following figure, you can see the header buttons created in the code snippet below. A click on the Left or Right buttons activates the previous or next tab page, respectively. A click on the Open button invokes the Open dialog. A click on the Ellipsis button invokes a message box.

TabbedGroup_CustomHeaderButtons

DevExpress.XtraTab.Buttons.CustomHeaderButton leftButton;
DevExpress.XtraTab.Buttons.CustomHeaderButton rightButton;
DevExpress.XtraTab.Buttons.CustomHeaderButton openButton;
DevExpress.XtraTab.Buttons.CustomHeaderButton ellipsisButton;
DevExpress.XtraLayout.LayoutControlGroup group1;
DevExpress.XtraEditors.PictureEdit pictureEdit;
DevExpress.XtraLayout.TabbedControlGroup tabbedGroup;

//...

// Create a LayoutControl.
DevExpress.XtraLayout.LayoutControl lc = new DevExpress.XtraLayout.LayoutControl();
lc.Dock = System.Windows.Forms.DockStyle.Fill;
this.Controls.Add(lc);
// Lock the layout control to prevent excessive updates.
lc.BeginUpdate();
try {
    // Create a tabbed group within the root group.
    tabbedGroup = lc.Root.AddTabbedGroup();
    tabbedGroup.Name = "TabbedGroup";
    // Add a new group as a tab to the tabbed group.
    group1 = tabbedGroup.AddTabPage() as DevExpress.XtraLayout.LayoutControlGroup;
    group1.Name = "LayoutControlGroup1";
    group1.Text = "Photo";
    // Add a new layout item to the group that will display an image.
    DevExpress.XtraLayout.LayoutControlItem item1 = group1.AddItem();
    item1.Name = "LayoutControlItem1";
    pictureEdit = new DevExpress.XtraEditors.PictureEdit();
    item1.Control = pictureEdit;
    // Hide the item's text region.
    item1.TextVisible = false;
    // Add a new group to the tabbed group.
    DevExpress.XtraLayout.LayoutControlGroup group2 = tabbedGroup.AddTabPage() as DevExpress.XtraLayout.LayoutControlGroup;
    group2.Name = "LayoutControlGroup2";
    group2.Text = "Notes";
    //...
    // Make the first tab page active.
    tabbedGroup.SelectedTabPage = group1;

    // Add custom header buttons.
    // Create two buttons with predefined icons.
    leftButton = new DevExpress.XtraTab.Buttons.CustomHeaderButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Left);
    rightButton = new DevExpress.XtraTab.Buttons.CustomHeaderButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Right);
    // Create a button with a custom icon.
    openButton = new DevExpress.XtraTab.Buttons.CustomHeaderButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph);
    openButton.Image = DevExpress.Images.ImageResourceCache.Default.GetImage("office2013/actions/open_16x16.png");
    // Add created buttons to the custom button collection.
    tabbedGroup.CustomHeaderButtons.AddRange(new DevExpress.XtraTab.Buttons.CustomHeaderButton[] { leftButton, rightButton, openButton });
    // Create a button with the handled Click event.
    ellipsisButton = new DevExpress.XtraTab.Buttons.CustomHeaderButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis);
    ellipsisButton.Click += EllipsisButton_Click;
    tabbedGroup.CustomHeaderButtons.Add(ellipsisButton);
    // Handle the CustomHeaderButtonClick event, which fires when a custom header button is clicked.
    tabbedGroup.CustomHeaderButtonClick += TabbedGroup_CustomHeaderButtonClick;
}
finally {
    // Unlock and update the layout control.
    lc.EndUpdate();
}

//...

private void TabbedGroup_CustomHeaderButtonClick(object sender, DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs e) {
    // Handle the Left button click.
    if (e.Button == leftButton && tabbedGroup.SelectedTabPageIndex > 0)
        tabbedGroup.SelectedTabPageIndex--;
    // Handle the Right button click.
    if (e.Button == rightButton && tabbedGroup.SelectedTabPageIndex < tabbedGroup.TabPages.Count - 1)
        tabbedGroup.SelectedTabPageIndex++;
    // Handle the Open button click. Executed only when the Photo tab page is active (the group1 tab page).
    if (e.Button == openButton && ((DevExpress.XtraLayout.Tab.LayoutTabPage)e.ActivePage).Group == group1)
        pictureEdit.LoadImage();
}

// Handle the Ellipsis button click.
private void EllipsisButton_Click(object sender, EventArgs e) {
    MessageBox.Show("Ellipsis button is clicked.");
}
See Also