Click here to Skip to main content
15,889,723 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how to close a form when open a new form in panel of splitcontainer
Posted
Updated 23-May-12 17:50pm
v2
Comments
Sergey Alexandrovich Kryukov 23-May-12 21:42pm    
Not clear. And what's the problem, broken MSDN?
--SA
ThanhThanhNguyen 23-May-12 22:03pm    
I mean example like folder of window system. when you click a link on left of tree folder then info of folder you chose will display on right panel. When u chose another link on left menu then info of folder you chose will display on right panel and remove all info of folder you opened before

The short answer is: Form.Close(), http://msdn.microsoft.com/en-us/library/system.windows.forms.form.close.aspx[^].

The details of the question are not clear at all. A form, pathological cases aside, cannot be in a panel. Yes, you can stick it into a panel as a child control, but normally it would throw an exception, and I see no situations where it could be needed.

Besides, closing a form by this call is usually not what people typically do in a reasonable design. You should understand that you won't be able to open the same instance of the form again. Just to warn you…

I would advise that you ask questions providing more detail, starting with the purpose of the technique in question and the ultimate goals of your application.

—SA
 
Share this answer
 
Comments
VJ Reddy 24-May-12 0:52am    
Nice answer. 5!
Sergey Alexandrovich Kryukov 24-May-12 1:23am    
Thank you, VJ.
--SA
Get the instance of opened form and call its close method. Form has a close method.

e.g.

you have got a form1

you can do form1.Close();

if you don't have access to that form then you can raise an event to close it as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900