Check if a specific tab page is selected (active)

Naufal Fikri picture Naufal Fikri · Dec 28, 2011 · Viewed 127.7k times · Source

I am making an event to check if specific tab page in a tab control is active.

The point is, it will trigger an event if that tab page in a tab control is the currently selected tab. Any code that will give me what I need?

Answer

V4Vendetta picture V4Vendetta · Dec 28, 2011

Assuming you are looking out in Winform, there is a SelectedIndexChanged event for the tab

Now in it you could check for your specific tab and proceed with the logic

private void tab1_SelectedIndexChanged(object sender, EventArgs e)
{
     if (tab1.SelectedTab == tab1.TabPages["tabname"])//your specific tabname
     {
         // your stuff
     }
}