1

I am programming an applicaion with visual studio and c#. it has a Parent Form (FormParent) which is a MdiContainer and contains a toolstrip. the FormParent Conatins and a child Form (FormChild). So I open other Forms inside of it like FormUser.

Suppose I have a open FormUser, how can I close this FormUser when I click the toolstrip button ( for example the save one)?

Thank you

DerStarkeBaer
  • 669
  • 8
  • 28
nnmmss
  • 2,850
  • 7
  • 39
  • 67

1 Answers1

1

I did This and worked

  FormUser obj = (FormUser)Application.OpenForms["FormUser"];                
  obj.Close(); 

also thank you to @JQSOFT answer with a little edit another solution is :

  Application.OpenForms.OfType<FormUser>().FirstOrDefault().Close();
nnmmss
  • 2,850
  • 7
  • 39
  • 67