Link to home
Start Free TrialLog in
Avatar of AndyC1000
AndyC1000

asked on

C# How to disable Tab Page in Tab Control

Hello,

I've been unsuccessful disabling tab pages in my app.  

Prior to the user selecting 'Run' I require the result tabs to be disabled (preferrably invisible, greyed out ok).

I've tried:
this.ExampleTabPage.Enabled = false;

athough it makes no difference.

The only way I see it working is to add ExampleTabPage to the TabControl when the Run() has been completed.

Any suggestions?

MyPages.designer.cs configures the tabs, including the RunTab. The RunTab contains the RunControl.

I'm having difficulty working out how to update the tabs in the RunControl. I haven't updated designer variables before.

Thanks
Avatar of Cong Minh Vo
Cong Minh Vo
Flag of Viet Nam image

TabPage also inherit the control properties.

Control tab = new Control;

tab = TabPage1; //your tabpage name

tab.Enable = False;
another way is to encapsulate everything on your tab page in a group box and disable the group box. When disabled, all child controls within the group box will be inaccessible.
ASKER CERTIFIED SOLUTION
Avatar of Temizh
Temizh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BlnGuy
BlnGuy

If you want to disable all controls on a single tab page but still leave the page accessible, maybe on a configuration dialog, you may only want to disable all child controls of this page.

You can achieve this with the following code:
foreach (Control c in tabPage2.Controls)
{
    c.Enabled = false;
}

Open in new window

In my example I just wanted to disable all controls, that reside on tabPage2. Instead of "tabPage2" use your control's name in the foreach loop.