Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable a specific tabpage on runtime

Status
Not open for further replies.

swreng

MIS
Jun 22, 2006
90
GR
Hi to all,

I would like to do a simple thing with a tabcontrol but i can understand how.

I have a tabcontrol with 2 tabpages and i would like to disable the second tabpage before the user fill some data on the first the point is that i can't find Enabled or Locked or ReadOnly Property.

This is my code

if(txtContract.text=="")
{
tabdata.TabPages[1].Enabled ????=false
// How can i disable the tabpage[1]
// in order the user can not press the tabpage button
}



I have a thought to scan all the controls of the tabpage[1] and disable it one by one but i am wondering if there is a smarter way.

Many thanks

Ta
 
This question comes down to a matter of design in my opinion.

There is no Enabled method on a tabpage. But ask yourself how many tab pages you have... and how many controls on each tab page you have, and how many of those you use at one time...

When you create a few forms - do you create all the forms in one class? Of course not. That would be stupid.

So the suggestion I have for you is this - change your design. Have each "tabpage" as a custom control that you add to your framework form (the one that contains the tab control.) Then you can simply associate a tab page number to a UserControl using a dictionary. And of course a usercontrol has an Enabled propery. So you could bring the tab page up but the control inside is disabled.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top