Disabling individual Tabs in form load

Hello,
I am using the Windows forms TAB CONTROL and am disabling the tabpages 1 and 2 in the form load event using 

tControl.TabPages(1).Enabled = False
tControl.TabPages(2).Enabled = False

I dont know why, but this is not working! The documentation shows that the code is right
Is there something I am missing
I feel pretty lost now


Answer this question

Disabling individual Tabs in form load

  • Eric Jarvi MSFT

    I've had the same problem on an app with loads of tabs, some of which needed to appear depending on where the user was, what privileges they had etc - and I did what Jacob said: just removed them and added them and it worked fine... enable/disable seem to be bloatware methods as far as I can see since they don't seem to work (or at least do something different than you'd expect)!

    Mike.

  • Ahmed Chaudhary

    Rather than enable and disable them, why not simply remove them from the tabpages collection   Then, when needed, you can add them back in...
  • efonsecab

    holde the collection in another collection class, thus you could remove and add the tabs witouth recreating it over and over again
  • pons68

    According to current design when TabPage within TabControl is disabled, all controls on this page are disabled(grayed out), but actual tab portion of the TabPage is drawn enabled (NOT grayed out).
    In order to obtain "disabled" look you will need to owner draw your tabs.

  • DLLarson

    You won't need to hold them in another class... The form on which the TabControl resides has the references and declarations to the TabPages.  Not to mention that they are instantiated on load (in initializeComponent) regardless if they will be present in the collection.  So, the instances themselves can be added and removed at will.
  • Disabling individual Tabs in form load