I wan to Hide Parent window when it's child will be shown and when child window will be closed again parent window should again visible.
ChildForm s=new ChildForm();
It's not working how to do that.
First of all, you should understand that child-form dependency is rendered defunct for forms. You can override it by assigning —SA
TopLevel of the form to false, but… don't even try, there is nothing good on doing so; you would simply get one form inside another, which makes no sense.
You code is "not working", just because
this.Parent for a form is really null, normally. Also, you should never close a form if you plan on showing again; you better need to hide it (in the
FormClosing event, too).
You need to change the design to control the visibility, which is not a problem at all. First of all, I would recommend to use only one form. What are now forms, could be separate panel showing or hiding in the form. If you still need more forms, which I would not recommend, you need to use hiding and showing, not closing. The problem is that the code showing one form and hiding another form should be done in the content where the references to both forms are already known. The forms are pretty much independent; one form is unaware of others, so you need to provide a reference to another form. How to do it, depends on your purpose, but is trivial.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)