tab control

  • Thread starter Thread starter Wajih-ur-Rehman
  • Start date Start date
W

Wajih-ur-Rehman

I have a tab control on my form. It contains 2 tab pages. How can i disable
a tab page. Please note that there is no Enabled property of a Tab Page?
Thanx in advance!
 
I think you can do the following to control appearance of tab pages:

Lets say you have the following code automatically added to your .cs file
when you trag a tab control on a page and add some pages:

private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;

The trick to control which tabs appear is by modifying the collection of
tabpages in the TabControl object.

So to not show the tabPage2 I would try adding in the initialization code
the following:

tabControl1.TabPages.Remove(tabPage2);

When you need the page to appear you could call:

tabControl1.TabPages.Add(tabPage2);

Give me some feedback if that actually works in your app since coding is not
anymore my main job.

Robert Sentgerath
 
There isn't a way to disable a tab page. I struggeled
with this one for a while, too. The only thing you can
do is put a check in the tab control's
SelectedIndexChanged method to see if you want/can
display the selected tab. If you don't then set the
SelectedTab property to another page so that the selected
one isn't displayed.

Doug
 
Back
Top