dashboard-devexpress-dot-dashboardwin-dot-dashboardviewer-dot-getselectedtabpageindex-x28-system-dot-string-x29.md
Gets the index of the selected page in the specified tab container.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public int GetSelectedTabPageIndex(
string tabContainerName
)
Public Function GetSelectedTabPageIndex(
tabContainerName As String
) As Integer
| Name | Type | Description |
|---|---|---|
| tabContainerName | String |
A String that is the TabContainerDashboardItem.ComponentName property value and identifies the tab container.
|
| Type | Description |
|---|---|
| Int32 |
An integer that is the index in the TabContainerDashboardItem.TabPages collection.
|
The following code implements tab navigation in the TabContainerDashboardItem control.
View Example: How to navigate tabs using custom tab header buttons or set up a slide show
using DevExpress.DashboardCommon;
using System.Linq;
// ...
enum NextPrevValue {
Next,
Prev
}
void ShowNextPrevTab(NextPrevValue value) {
Dashboard dashboard = dashboardViewer.Dashboard;
TabContainerDashboardItem tabContainer = dashboard.Items.SingleOrDefault(i => i is TabContainerDashboardItem) as TabContainerDashboardItem;
if(tabContainer != null) {
int increment = value == NextPrevValue.Next ? 1 : -1;
string tabContainerName = tabContainer.ComponentName;
int selectedIndex = dashboardViewer.GetSelectedTabPageIndex(tabContainerName);
int pageCount = tabContainer.TabPages.Count;
dashboardViewer.SetSelectedTabPage(tabContainerName, (selectedIndex + pageCount + increment) % pageCount);
}
}
Imports DevExpress.DashboardCommon
Imports System.Linq
' ...
Friend Enum NextPrevValue
[Next]
Prev
End Enum
Private Sub ShowNextPrevTab(ByVal value As NextPrevValue)
Dim tabContainer As TabContainerDashboardItem = TryCast(dashboard.Items.SingleOrDefault(Function(i) TypeOf i Is TabContainerDashboardItem), TabContainerDashboardItem)
If tabContainer IsNot Nothing Then
Dim increment As Integer = If(value = NextPrevValue.Next, 1, -1)
Dim tabContainerName As String = tabContainer.ComponentName
Dim selectedIndex As Integer = dashboardViewer.GetSelectedTabPageIndex(tabContainerName)
Dim pageCount As Integer = tabContainer.TabPages.Count
dashboardViewer.SetSelectedTabPage(tabContainerName, (selectedIndex + pageCount + increment) Mod pageCount)
End If
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetSelectedTabPageIndex(String) method.
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.
string tabContainerName = tabContainer.ComponentName;
int selectedIndex = dashboardViewer.GetSelectedTabPageIndex(tabContainerName);
int pageCount = tabContainer.TabPages.Count;
winforms-dashboard-window-calculation-example/CS/WindowCalculationExample/Form1.cs#L94
{
int selectedIndex = dashboardViewer1.GetSelectedTabPageIndex(timedTabContainerName);
int pageCount = ((TabContainerDashboardItem)dashboardViewer1.Dashboard.Items[timedTabContainerName]).TabPages.Count;
Dim tabContainerName As String = tabContainer.ComponentName
Dim selectedIndex As Integer = dashboardViewer.GetSelectedTabPageIndex(tabContainerName)
Dim pageCount As Integer = tabContainer.TabPages.Count
winforms-dashboard-window-calculation-example/VB/WindowCalculationExample/Form1.vb#L74
If Not Equals(timedTabContainerName, Nothing) Then
Dim selectedIndex As Integer = dashboardViewer1.GetSelectedTabPageIndex(timedTabContainerName)
Dim pageCount As Integer = CType(dashboardViewer1.Dashboard.Items(timedTabContainerName), TabContainerDashboardItem).TabPages.Count
GetSelectedTabPageIndex(String)
See Also