Search code examples
c#tabcontrolwinformstabpage

How to hide/block a tab in c#?


I need to know how to make a tab item in a tab control unavailable for a certain kind of user.

The thing goes that after making 'log in', if the user is not the administrator, he will have one or two tabs unavailable. The admin will have access to the whole system.

I just want to make the tabs un-clickable. What are my options?

Thanks in advance


Solution

  • In general:

    System.Windows.Forms.TabPage.Enabled= false;

    System.Windows.Forms.TabPage.Visible= false;

    I prefer next approach:

    tabAdmin.Visible = isAdmin;