Disable tab pages in VC#

Hello guys,

Well i am bit struck in disabling (Graying out as visible and user cant select them) at form load itself in [b]C#[/b]. I mean, i have designed a form with 3 tab pages in tab control. And now, when i load the form, the rest 2 tab pages should be grayed out so that user cant select those tab pages and move to those tab pages leaving tab page 1. I need a small code snippet for this. Plz i hope, some on will help me.


P.S: I am using WinXp and Visual Studio 2005.


  • I'm not exactly sure how to disable (grey out) tab pages, but it is simple enough to prevent user access. The following code only allows users to access the first TabPage. You can update the condition to allow access to other tabs as necessary.

    private void tabControl1_Selected(object sender, TabControlEventArgs e)
    if (e.TabPageIndex > 0)
    this.tabControl1.SelectedIndex = 0;
    MessageBox.Show("You do not have permission to view this Tab." ,
    Permissions Error");
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion