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.Enable d = 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
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.Enable
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
http://msdn.microsoft.com/en-us/library/252t3cec.aspx
TabPage also inherit the control properties.
Control tab = new Control;
tab = TabPage1; //your tabpage name
tab.Enable = False;
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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:
You can achieve this with the following code:
foreach (Control c in tabPage2.Controls)
{
c.Enabled = false;
}
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.