windowsforms-devexpress-dot-xtralayout-dot-tabbedgroup-0ad657ab.md
Provides access to the collection of custom buttons displayed in the tabbed group header.
Namespace : DevExpress.XtraLayout
Assembly : DevExpress.XtraLayout.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Behavior")]
public virtual CustomHeaderButtonCollection CustomHeaderButtons { get; }
<DXCategory("Behavior")>
Public Overridable ReadOnly Property CustomHeaderButtons As CustomHeaderButtonCollection
| Type | Description |
|---|---|
| CustomHeaderButtonCollection |
The CustomHeaderButtonCollection object that represents a collection of custom buttons displayed in the tabbed group header.
|
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.
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.");
}
Dim leftButton As DevExpress.XtraTab.Buttons.CustomHeaderButton
Dim rightButton As DevExpress.XtraTab.Buttons.CustomHeaderButton
Dim openButton As DevExpress.XtraTab.Buttons.CustomHeaderButton
Dim WithEvents ellipsisButton As DevExpress.XtraTab.Buttons.CustomHeaderButton
Dim group1 As DevExpress.XtraLayout.LayoutControlGroup
Dim pictureEdit As DevExpress.XtraEditors.PictureEdit
Dim WithEvents tabbedGroup As DevExpress.XtraLayout.TabbedControlGroup
'...
' Create a LayoutControl.
Dim lc As New DevExpress.XtraLayout.LayoutControl()
lc.Dock = System.Windows.Forms.DockStyle.Fill
Me.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 = TryCast(tabbedGroup.AddTabPage(), DevExpress.XtraLayout.LayoutControlGroup)
group1.Name = "LayoutControlGroup1"
group1.Text = "Photo"
' Add a new layout item to the group that will display an image.
Dim item1 As DevExpress.XtraLayout.LayoutControlItem = 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.
Dim group2 As DevExpress.XtraLayout.LayoutControlGroup = TryCast(tabbedGroup.AddTabPage(), 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)
tabbedGroup.CustomHeaderButtons.Add(ellipsisButton)
Finally
' Unlock and update the layout control.
lc.EndUpdate()
End Try
'...
' Handle the CustomHeaderButtonClick event, which fires when a custom header button is clicked.
Protected Sub TabbedGroup_CustomHeaderButtonClickn_Click(ByVal sender As System.Object,
ByVal e As DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs) Handles tabbedGroup.CustomHeaderButtonClick
' Handle the Left button click.
If e.Button Is leftButton AndAlso tabbedGroup.SelectedTabPageIndex > 0 Then
tabbedGroup.SelectedTabPageIndex -= 1
End If
' Handle the Right button click.
If e.Button Is rightButton AndAlso tabbedGroup.SelectedTabPageIndex < tabbedGroup.TabPages.Count - 1 Then
tabbedGroup.SelectedTabPageIndex += 1
End If
' Handle the Open button click. Executed only when the Photo tab page is active (the group1 tab page).
If e.Button Is openButton AndAlso DirectCast(e.ActivePage, DevExpress.XtraLayout.Tab.LayoutTabPage).Group Is group1 Then
pictureEdit.LoadImage()
End If
End Sub
Protected Sub EllipsisButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ellipsisButton.Click
MessageBox.Show("Ellipsis button is clicked.")
End Sub
See Also