How to find out active form

May 7 2011 5:23 AM
hai expert..................

i have opened more than 2 forms. and i wnt the name of active form among them.. i used the following code, bt its not working...plz help me...


for (int iCnt = (Application.OpenForms.Count - 1); iCnt >= 0; iCnt--)
{
     if (Application.OpenForms[iCnt].Focused == true)
      {
         sForm_name = Application.OpenForms[iCnt].Name;
         break;
      }

}

thanks in advance...............

Answers (4)