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

XtraTabControl.CustomHeaderButtonClick Event

Occurs when a custom header button is clicked.

Namespace: DevExpress.XtraTab

Assembly: DevExpress.XtraEditors.v18.1.dll

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);
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomHeaderButtonClick event.

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