How to Disable Tab Pages in Tab Control in Windows Application C#

Hi, Here we are going to learn about Windows application Tab Control in asp.net.

Tab control is used to display multiple dialog on single Windows Form. we can switch from one tab pages to other in Tab control in Windows application with c# controls.

All single dialog tab known as a Tab pages… one Tab control has multiple Tab Pages and we can add or remove Tab pages in Tab Control…

Here we lean How to Disable one or more Tab pages in Tab control in asp.net.

So, We have a property Enabled for Enable and Disable Tab pages effects…

tabPage1.Enabled = false;

tabPage3.Enabled = true;

But, here we want to Disable Tab page click event, means we can not click on that Tab pages so we need to do follow method….

First design windows form with one Tab control with Three Tab pages in asp.net c#.

Here we show you First Tab page is normal as simple and Second Tab page Click event is Disable and we make Third tab page Enabled false…..

Here in below figure1 we can see the simple out put of Tab page 1 click event…

Disable Tab pages in Tab control in Windows Application.
Disable Tab pages in Tab control in Windows Application.

Write below code in tabcontrol selectedindexchanged events…

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabPage2)
{
tabControl1.SelectedTab = tabPage1;
MessageBox.Show("You don't have permission !!", "Meera Academy");

}
if (tabControl1.SelectedTab == tabPage3)
{

tabPage3.Enabled = false;
}
}

Now, when we click on Tab page2 then we can get message like you don’t have permission to click this tab pages.

Here we have Disable Tab page 2 click event in Tab control in ASP.Net with c# controls.

How to disable tab pages click event in tab control c#
How to disable tab pages click event in tab control c#

The last Third Tab page 3 click event is not disabled but the Content of tab pages3 is is Disable so we cant see the out put of like below screen……

How to disable tab pages click event in tab control c#
How to disable tab pages click event in tab control c#

I hope you will enjoy this Enabled/Disable Tab pages Click event in Tab page c# controls in Windows application……

Leave a Reply

Your email address will not be published. Required fields are marked *