Skip to main content

XtraTabControl.CustomHeaderButtonClick Event

Occurs when a custom header button is clicked.

Namespace: DevExpress.XtraTab

Assembly: DevExpress.XtraEditors.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Behavior")]
public event CustomHeaderButtonEventHandler CustomHeaderButtonClick

Event Data

The CustomHeaderButtonClick event's data class is CustomHeaderButtonEventArgs. The following properties provide information specific to this event:

Property Description
ActivePage Gets an active tab page within the tab control.
Button Gets the currently processed custom header button.

Remarks

A tab control has built-in header buttons (see the XtraTabControl.HeaderButtons property). You can also add any number of custom header buttons to the tab control using the XtraTabControl.CustomHeaderButtons property. Each custom button is a CustomHeaderButton object that provides a variety of properties such as EditorButton.Caption, EditorButton.Kind, EditorButton.Tag, etc.

After you have added custom buttons, you need to add a functionality to them. Handle the CustomHeaderButtonClick event to perform actions on button clicking.

Example

The example demonstrates how to add two custom header buttons to a tab control and use the XtraTabControl.CustomHeaderButtonClick event to add or remove tabs.

Using Custom Header Buttons

using DevExpress.XtraTab;
using DevExpress.XtraTab.Buttons;
using DevExpress.XtraEditors.Controls;

private void Form1_Load(object sender, EventArgs e) {
    xtraTabControl1.CustomHeaderButtons.Add(new CustomHeaderButton(ButtonPredefines.Plus));
    xtraTabControl1.CustomHeaderButtons.Add(new CustomHeaderButton(ButtonPredefines.Minus));
}

int counter = 0;
private void xtraTabControl1_CustomHeaderButtonClick(object sender, DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs e) {
    if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Plus) {
        xtraTabControl1.TabPages.Add("page" + (++counter));
    }
    else {
        if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Minus) {
            xtraTabControl1.TabPages.Remove(e.ActivePage as XtraTabPage);
        }
    }
}
See Also