I have made a parent form which can call and display two child forms in it.
But how 1st child form can be closed automatically when second child form is called?
I have made a parent form which can call and display two child forms in it.
But how 1st child form can be closed automatically when second child form is called?
When you make a form in windows forms as MDI Parent form then it will have a property called MdiChildren
that contains the collections of opened child forms. before opening the second form, you can write the following code to close the first form.
this.MdiChildren[0].Close();
if multiple child forms are available then you need to access this.MdiChildren
using a foreach
loop and search for Form1 and close it.