views:

170

answers:

4

Say for instance I have a C# Winforms applciations that uses a tabcontrol with four different tab pages. Above this control on the main form are a series of groupboxes containing various buttons and textboxes relevant to the different functions running on each individual tabpage.

If I am using a particular tabpage that only makes use of some of the controls, I want to disable the others so that the user cannot accidentally click the wrong buttons.

Example Logic:

If(tabpage1.selected)   
{
   button3.Disabled();
}

Does anyone know of a way of implementing this kind of functionality?!

Regards,

EDIT:

Essentially I want to be able to disable groupboxes!!

+5  A: 
button3.Enabled = false
Perica Zivkovic
A: 
button3.Enabled = false;
tomfanning
+4  A: 

Rather than calling .Disabled(), set the .Enabled property to false. To make this easier, you can put the related controls into the same container (Panel control), and just set Enabled to false for that container.

Joel Coehoorn
Wow didn't realise it was literally that simple, Cheers!
Goober
+2  A: 

Instead of:

if(tabpage1.selected)   
{
   button3.Disabled();
}

use:

buttom3.Enabled = !tabpage1.selected;
jjnguy