Windows Develop Bookmark and Share   
 index > Windows Forms General > Easily disable tabs in TabControl
 

Easily disable tabs in TabControl

ie. tabControl.TabPages[1].Enabled = false;
MigrationUser 1  Wednesday, February 12, 2003 5:51 PM
Do you want this to disable all the controls on the TabPage, or disable the tab itself and prevent it from being clicked?

 -mike
MigrationUser 1  Wednesday, February 12, 2003 7:01 PM
I would like to be able to disable individual tabs.  As it stands now I have to remove and add these tabs through code.  It is not all that difficult, but one would expect that something such as having a disabled tab would be easily implemented.  I can see in the MSDN Library that the framework notes a TabPage has an enabled field.  However, it is not available in my version of .NET, which happens to be the latest Architect Edition.  Overall, I like the Tab Control over the previous versions.  Especially the DockPadding, and Dock Fields.  They make creating a visually appealing UI as easy as it should be...
MigrationUser 1  Thursday, February 13, 2003 9:48 AM
Ok, I get it and this is good idea.  We will look into adding Tab disable functionality in the next verison of Windows Forms. 

 - mike
MigrationUser 1  Tuesday, February 18, 2003 4:23 PM
TabPages[0].Enabled = false; will currently work, we use it in a lot of our forms with TabControls.  It Enables or disables all of the controls on the tabPage but not the actual tab it self
MigrationUser 1  Tuesday, February 18, 2003 6:16 PM
RIght. But I (and obviously others) would like to be able to disable the tab itself. I know this may not agree with the standard "Windows" way of working, but I've looked and looked for a way to do this, early in the .NET development cycle. And it's just not there.
MigrationUser 1  Wednesday, February 19, 2003 9:15 PM
Easily done like this:

private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
{
  switch  ((sender as TabControl).SelectedIndex) 
  {
    case 0:
    {
      if (((sender as TabControl).SelectedTab as TabPage).Enabled == false)
      {
        (sender as TabControl).SelectedIndex = 1;  
      }
      break;
    }
  }      
}
MigrationUser 1  Thursday, January 15, 2004 1:37 PM

You can use google to search for other answers

Custom Search

More Threads

• ComboBox
• MDI Form bugs - VS2005 - .Net v2.0.50727
• Return key
• checked list box
• Tooltips don't come back
• Generating code via codedom and assigning version to assembly
• Custom DATASOURCE PROPERTY OF COMBOBOX AT RUNTIME to Connect to DB SQLSERVER
• remove & suppress blank space of header and footer in crystal report
• How to make drop-down menu of Toolbar?
• How to save drawing from picture box drawn in GDI+ into bmp file type?