Back to Devexpress

CustomHeaderButtonCollection Class

windowsforms-devexpress-dot-xtratab-dot-buttons-eaf01501.md

latest5.9 KB
Original Source

CustomHeaderButtonCollection Class

A custom header button collection for tab controls.

Namespace : DevExpress.XtraTab.Buttons

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[ListBindable(false)]
public class CustomHeaderButtonCollection :
    CollectionBase
vb
<ListBindable(False)>
Public Class CustomHeaderButtonCollection
    Inherits CollectionBase

The following members return CustomHeaderButtonCollection objects:

Remarks

You can add custom header buttons to an XtraTabControl and to a DocumentGroup (within a DocumentManager). The XtraTabControl.CustomHeaderButtons property allows you to add custom header buttons to an XtraTabControl. Use the IDocumentGroupProperties.CustomHeaderButtons property to add custom header buttons to a DocumentGroup. The CustomHeaderButtonCollection consists of CustomHeaderButton elements that can be accessed using indexer notation.

You can edit the CustomHeaderButtonCollection class at design time via the collection editor:

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.

csharp
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);
        }
    }
}
vb
Imports DevExpress.XtraTab
Imports DevExpress.XtraTab.Buttons
Imports DevExpress.XtraEditors.Controls

Public Class Form1
    Dim counter As Integer = 0
    Private Sub XtraTabControl1_CustomHeaderButtonClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs) Handles XtraTabControl1.CustomHeaderButtonClick
        If e.Button.Kind = ButtonPredefines.Plus Then
            counter = counter + 1
            XtraTabControl1.TabPages.Add("page" + counter.ToString)
        Else
            If e.Button.Kind = ButtonPredefines.Minus Then
                XtraTabControl1.TabPages.Remove(e.ActivePage)
            End If
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        XtraTabControl1.CustomHeaderButtons.Add(New CustomHeaderButton(ButtonPredefines.Plus))
        XtraTabControl1.CustomHeaderButtons.Add(New CustomHeaderButton(ButtonPredefines.Minus))
    End Sub
End Class

Inheritance

Object CollectionBase CustomHeaderButtonCollection

See Also

CustomHeaderButtonCollection Members

XtraTabControl.CustomHeaderButtons

IDocumentGroupProperties.CustomHeaderButtons

CustomHeaderButton

XtraTabControl

DocumentGroup

DocumentManager

DevExpress.XtraTab.Buttons Namespace