RSS

Tag Archives: c# open a new form then close the current form?

how check if the form is already open then Close all open form


Hi dear,

his is what I used to close all open forms (except for the main form)

private void CloseOpenForms()
    {

           // Close all open forms - except for the main form.  (This is usually OpenForms[0].
           // Closing a form decrmements the OpenForms count
           while (Application.OpenForms.Count > 1)
           {
               Application.OpenForms[Application.OpenForms.Count-1].Close();
           }
    }

 

 

 
Leave a comment

Posted by on March 15, 2013 in WinForm

 

Tags: , , ,