ShowDialog will open form2 as a modal dialog box, that is, the program will not continue until form2 is closed (either by the user or by any of the form2 event handlers. To open form2 weak, i.e. call Show . Then you can call form2.Close() at any time.
Side note: Forms opened with Show are automatically deleted when the user closes them. (On the other hand, modal forms, i.e. those shown with ShowDialog() , must be Dispose d manually). That is, it is possible that form2 already configured when you want to manually close it. I think that calling Close on the arranged form does not cause anything unpleasant; I think that it just calls Dispose second time.
stakx source share