1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[VB.NET Help?] Disabling a Tab in Tab Control

Discussion in 'Code Snippets and Tutorials' started by Lightning, Sep 26, 2009.

  1. Lightning

    Lightning Administrator
    Staff Member

    Joined:
    Nov 8, 2008
    Messages:
    3,021
    Likes Received:
    195
    Gender:
    Male
    Location:
    Florida, USA
    Is there a way to disable a tab in tab control while others are available?

    I've tried basic naming the tabcontrol and tab and .Enabled = False, but it didn't seem to work.

    Help?
     
  2. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    my example use the tab control with default name.
    The code below will disable the page 2 of tabcontrol.
    You don't need to specify the control first.
    Code (Text):
    1. TabPage2.Enabled = False
     
  3. Lightning

    Lightning Administrator
    Staff Member

    Joined:
    Nov 8, 2008
    Messages:
    3,021
    Likes Received:
    195
    Gender:
    Male
    Location:
    Florida, USA
    There's no error for the one you gave me (Tharoux), but it made no difference. I can still go to it and stuff...

    EDIT: Never mind, I can't do anything there.

    I was kinda looking more for it to be not visible.
     
  4. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    Ah... that's not the same thing !!!
    no visible property ??
     
  5. Lightning

    Lightning Administrator
    Staff Member

    Joined:
    Nov 8, 2008
    Messages:
    3,021
    Likes Received:
    195
    Gender:
    Male
    Location:
    Florida, USA
    Yeah, there is no 'visible property'. It's weird...o_O
     
  6. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    You could possibly remove the tab at runtime to make it not visible, but I'm sure it could mess up some of your coding if you're referencing to the tabcontrol's tabs using indexes.