How do I detect a change of tab page in TabControl prior to SelectedIndexChanged event?

Add such an event to the tabControl when form_load:

tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_Selecting);

void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
    TabPage current = (sender as TabControl).SelectedTab;

    // Validate the current page. To cancel the select, use:
    e.Cancel = true;

Leave a Comment