Wahéb
Wahéb

Reputation: 23

how to Selecting XtraTab via C# Code

I am making 2 XtraTab in my DetailGridControl, I want to do something like this :

if( XtraTab1 is selected ) 
{ 
   code ...
}
else if ( XtraTab2 is selected ) 
{ 
   code ... 
} 

But I don't know how can I select the XtraTab in the IF statement .

Upvotes: 1

Views: 96

Answers (1)

Hambone
Hambone

Reputation: 16387

There may be another way of accomplishing this, but the simplest and most effective way (without dwimmery or casting) I have found of both selecting a tab page and checking to see what tab page is selected is to use the SelectedTabPageIndex property of the tab control:

xtraTabControl1.SelectedTabPageIndex = 2

Selects the third tab.

if (xtraTabControl1.SelectedTabPageIndex == 0)

Checks to see if the first tab is the selected one or not.

Based on your construct, a switch statement would work nicely.

Upvotes: 1

Related Questions