Solved

C# How to disable Tab Page in Tab Control

Posted on 2011-09-12
6
3,709 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:AndyC1000
6 Comments
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 36526971
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36527323
TabPage also inherit the control properties.

Control tab = new Control;

tab = TabPage1; //your tabpage name

tab.Enable = False;
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 36528373
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Expert Comment

by:dimaj
ID: 36530330
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.
0
 
LVL 1

Accepted Solution

by:
Temizh earned 500 total points
ID: 36532320
a trick: cast your TabPage to Control, so that you can enable/disable the tab. you already can select tabs, but inside of the tabs will be enabled/disable according to your desire.

int index = 2; // which tab you want 0-based index
(tabControl1.TabPages[index] as Control).Enabled = false;

Open in new window


or

(tabContorl.SelectedTab as Control).Enabled = false;

Open in new window

0
 

Expert Comment

by:BlnGuy
ID: 36536171
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now