Back to Devexpress

XtraTabControl.SelectedTabPage Property

windowsforms-devexpress-dot-xtratab-dot-xtratabcontrol-684d96c0.md

latest6.1 KB
Original Source

XtraTabControl.SelectedTabPage Property

Gets or sets the currently selected tab page.

Namespace : DevExpress.XtraTab

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(null)]
[DXCategory("Behavior")]
public virtual XtraTabPage SelectedTabPage { get; set; }
vb
<DXCategory("Behavior")>
<DefaultValue(Nothing)>
Public Overridable Property SelectedTabPage As XtraTabPage

Property Value

TypeDefaultDescription
XtraTabPagenull

An XtraTabPage object which represents the tab page currently selected.

|

Remarks

Read this property’s value to determine which tab page is currently selected. Assign a tab page to this property to select it.

Disabled tab pages (pages whose XtraTabPage.PageEnabled property is set to false ) cannot be selected. If the tab control does not own any pages, the SelectedTabPage property returns a null reference.

When the SelectedTabPage property value changes, the XtraTabControl.SelectedPageChanged event raises.

The following code snippet switches active tabs with CTRL+1 and CTRL+2 key combinations.

csharp
xtraTabControl1.KeyDown += XtraTabControl1_KeyDown;

private void XtraTabControl1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.D1 && e.Control)
        this.xtraTabControl1.SelectedTabPage = xtraTabPage1;
    if (e.KeyCode == Keys.D2 && e.Control)
        this.xtraTabControl1.SelectedTabPage = xtraTabPage2;
}
vb
Private xtraTabControl1.KeyDown += AddressOf XtraTabControl1_KeyDown

Private Sub XtraTabControl1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
    If e.KeyCode = Keys.D1 AndAlso e.Control Then
        Me.xtraTabControl1.SelectedTabPage = xtraTabPage1
    End If
    If e.KeyCode = Keys.D2 AndAlso e.Control Then
        Me.xtraTabControl1.SelectedTabPage = xtraTabPage2
    End If
End Sub

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

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.

winforms-richedit-create-a-master-detail-report/CS/RichEditMasterDetailMailMerge/Form1.cs#L68

csharp
xtraTabControl1.SelectedTabPage = xtraTabPage4;
}

winforms-spreadsheet-use-cell-range-as-data-source/CS/RangeDataSource/Form1.cs#L23

csharp
xtraTabControl1.SelectedTabPage = tbGauge;
}

winforms-tab-control-custom-header-buttons/CS/XtraTabControl_CustomButtons/Form1.cs#L60

csharp
xtraTabControl1.TabPages.Add(page);
xtraTabControl1.SelectedTabPage = page;
UpdateButtons();

winforms-richedit-create-a-master-detail-report/VB/RichEditMasterDetailMailMerge/Form1.vb#L64

vb
xtraTabControl1.SelectedTabPage = xtraTabPage4
End Sub

winforms-spreadsheet-use-cell-range-as-data-source/VB/RangeDataSource/Form1.vb#L27

vb
xtraTabControl1.SelectedTabPage = tbGauge
End Sub

winforms-tab-control-custom-header-buttons/VB/XtraTabControl_CustomButtons/Form1.vb#L66

vb
xtraTabControl1.TabPages.Add(page)
xtraTabControl1.SelectedTabPage = page
UpdateButtons()

See Also

SelectedTabPageIndex

PageEnabled

SelectedPageChanged

SelectedPageChanging

Deselected

Deselecting

Selected

Selecting

UseMnemonic

SelectedPageChangeAnimationCompleted

XtraTabControl Class

XtraTabControl Members

DevExpress.XtraTab Namespace