muze 0 Junior Poster in Training

hello guys... In my program, user will first need to enter the credentials on Tab1, in order to be able to see the rest of the tabs (and controls on it). If wrong credentials are given then upon clicking any other tab, for a fraction of second it shows the other tab (onwhich I click: say Tab3) then switches almost immediately back to first tab, although the code works fine . Here is what I have tried so far

private void OnMouseDown(object sender, MouseEventArgs e) 
{
  if (e.Button == MouseButtons.Left)
  {
      if (tabMainTabCtrl.SelectedIndex != 0)
      {
        if (IsUserAuthenticated) // this is set when user is authenticated or not
          tabMainTabCtrl.SelectedIndex = m_iSelectedTab;
        else
          tabMainTabCtrl.SelectedIndex = 0;
      }
  }
}

private void tabMainTabCtrl_SelectedIndexChanged(object sender, EventArgs e)
{
     m_iSelectedTab = tabMainTabCtrl.SelectedIndex; //m_iSelectedTab: class level global variable
}

As I said, it works fine but it seems strange. So what can be a better solution? thnx for any input.