Gold Gold - 1 year ago 78
C# Question

How can I disable a tab inside a TabControl?

Is there a way to disable a tab in a TabControl?

I am using C#.

Answer Source

The TabPage class hides the Enable property. That was intentional as there's an awkward UI design problem with it. The basic issues are that disabling the page does not also disable the tab and disabling the tab with the Selecting event doesn't work when the TabControl has only one page.

It still works; you can hard-code the Enable property assignment. If the FUD is uncomfortable then you can simply do this:

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