Solved

C# How to disable Tab Page in Tab Control

Posted on 2011-09-12
6
4,186 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

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!

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

734 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