C# .NET - Tab Control

Asked By nikita kumar on 08-Oct-09 09:05 AM

Hi,

am using a Tab Control in my application in which through a page cs page,the current tab has to redirect another tab.for eg: it has to go to Tabpanel2 fromTabpanel 1...

.i used Tabpanel1.focus()...but its not working...can anyone help me plzzz?

reply

Deepak Sonawane replied to nikita kumar on 08-Oct-09 09:13 AM
Hi,
Windows TabControl is a useful control that allows you display multiple dialogs tabs on a single form by switching between the tabs.

You have to set
TabIndex property from code-behind as per your need :
this.tabControl1.TabIndex = 0;
 
Understanding the TabControl and TabPage class

A TabControl is a collection of tab pages and a tab page is the actual control that hosts other child controls. TabPage class represents a tab page.

TabControl class represents a TabControl. This class provides members (properties, methods, and events) to work with the TabControls. Table 1 lists the TabControl properties.

Property  Description
Alignment
Area of the control where the tabs are aligned.
Appearance
 
Visual appearance of the control's tabs.
DrawMode
 
A way that the control's tab pages are drawn.
HotTrack Value indicating whether the control's tabs change in appearance when the mouse passes over them.
ImageList
The images to display on the control's tabs.
ItemSize
 
Size of the control's tabs.
Multiline
 A value indicating whether more than one row of tabs can be displayed.
Padding
 
Amount of space around each item on the control's tab pages. 
RowCount
 
Returns the number of rows that are currently being displayed in the control's tab strip.
SelectedIndex
 
The index of the currently-selected tab page.
SelectedTab  Currently selected tab page.
ShowToolTips
 
The value indicating whether a tab's ToolTip is shown when the mouse passes over the tab.
SizeMode
 
The way that the control's tabs are sized.
TabCount
 Number of tabs in the tab strip.
TabPages
Returns the collection of tab pages in this tab control.

Use the SelectedIndex or SelectedTab

[)ia6l0 iii replied to nikita kumar on 08-Oct-09 09:51 AM
The tabcontrol would have a selectedIndex and all you need is to set it to the index of the tabpanel.
tabControl.SelectedIndex = 2;

You could also use the SelectedTab property of the tabControl if you have the tabpage object in hand. 
tabControl.SelectedTab = tabControl.tabPages[0];

Btw,is it tabpanel or tabpage?

Note: its been a long time since i worked with the tab control. The property names could have slightly varied :-)

Just write this

Vishal Chourasiya replied to nikita kumar on 09-Oct-09 12:18 AM

On Form_Load Event, Write

 tbAVTS.SelectedIndex = 0 ,  where tbAVTS is your TabControl'Id.