How to disable a C# .net tab inside a TabControl?

Standard

The TabPage class doesn’t have an Enable property. You can get a similar effect simply by setting the Enable property of the controls on that page. That also avoids the problem of dealing with a TabControl that has only one page. For example:

public static void EnableTab(TabPage page, bool enable) {
 foreach (Control ctl in page.ctls) ctl.Enabled = enable;
}

Or a better way, cast your TabPage to a Control, then set the Enabled property to false.

((Control)this.tabPage).Enabled = false;

Or

((Control)tbcSettings.TabPages[2]).Enabled = false;

Therefore, the tabpage’s header will still be enabled but its contents will be disabled.

Leave a Reply

Your email address will not be published. Required fields are marked *