-2

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?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
MSK
  • 11
  • 1

1 Answers1

0

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.

Ramesh Babu
  • 405
  • 4
  • 10