Solved

C# How to disable Tab Page in Tab Control

Posted on 2011-09-12
6
4,329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 70

Expert Comment

by:Éric Moreau
ID: 36528373
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

695 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