Here are some frequently asked questions about Windows Forms and their answers.
Browse by Tags
All Tags » TabControl (RSS)
-
|
The following code snippet shows how you can drag a TabPage from TabControl1 and drop it into TabControl2 (whose AllowDrop property must be set to True): [C#] // Source TabControl private void tabControl1_MouseMove( object sender, MouseEventArgs e ) ...
|
-
|
You can use the TabPage's Validating event to prevent a new tab page selection. Here are the steps: 1) Every time the user selects a new tab, make sure that the corresponding tab page gets the focus. You can do so as follows: private void tabControl1_SelectedIndexChanged...
|
-
|
It's a common mistake to try to use the Visible property of the TabPage to make the tab invisible. But this does not work (The Visible property of the TabPage is essentially obsolete). The TabControl doesn't provide you an easy way to do so. The...
|
-
|
To delete a tabpage, you use the tabControl1.Controls.Remove method. To add a new page as the last tab, use the tabControl1.Controls.Add method. Here is some sample code. // remove the selected tab tabControl1.Controls.Remove( tabControl1.SelectedTab...
|
-
|
Set the TabControl.Alignment property to TabAlignment.Bottom. tabControl1.Alignment = TabAlignment.Bottom; You can also change the tabs into buttons using the Appearance property and TabAppearance enums. Contributed from George Shepherd's Windows...
|
-
|
Listen to the Form's Activate event and set focus on the text box (using the Focus method). The common mistake is to try to set Focus in the Form_Load event. This is not possible because no Controls are visible at this time and hence focus cannot...
|
-
|
This seems to be a known issue with the TabControl designer. The designer seems to automatically reorder the tabs while serializing changes made in the designer. To work around this issue, in your constructor, after the call to InitializeComponent, you...
|
-
|
There are a couple of ways you could do select a tab page programmatically. This selects the second Tab page: tabControl.SelectedTab = this.tabPage2 This also selects the second Tab page: tabControl.SelectedIndex= 1; Contributed from George Shepherd's...
|
-
|
Set the TabControl's DrawMode to OwnerDraw, and then handle the DrawItem event to draw things yourself. Here are both VB and C# sample projects that display a gradient tab for the active tabpage. Contributed from George Shepherd's Windows Forms...
|