Hey all,

I've been trying to create an MDI tabbed control and I came across this article
http://www.devasp.net/net/articles/display/451.html. The code shown work perfectly except that it will only work if each tab page is an instance of form2. My problem is I want to use it for different forms i.e. form3 form4 etc.

The problem seems to lie with the selected index changed event as the foreach loop iterates through each instance of form2.

private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
{
         foreach (Form2 childForm in this.MdiChildren)
         {
             if (childForm.TabPag.Equals(tabControl1.SelectedTab))
              {
                   childForm.Select();
               }
                  }
}

Would anybody here be able to help me out to try and get this working with different forms?