Solved

C# How to disable Tab Page in Tab Control

Posted on 2011-09-12
6
3,539 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 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

19 Experts available now in Live!

Get 1:1 Help Now