Click here to Skip to main content
15,741,692 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
When a sub-form loads, I want the Parent form to minimize. This helps to avoid piling layers of Forms. How do we do this i.e. load one and minimize the previous form? I can't use hide() because I may want to use the parent form later. I have tried: Me.Parent.Windowstate=.minimized in SubForm Load, but this is not possible. Please help. Thanks
Sergey Alexandrovich Kryukov 19-Jan-12 17:37pm    
What is "me" in this example? It should be a control, not a form. Parent-child relationships between forms are not operational if you use it in normal way. One form should not be a parent for another one (you could do it, but in pathological way, but assigning TopLevel to false; the result is ugly).

Can you make a code sample (shortest possible, not the code of your application) to manifest the problem? If you can, use "Improve question" above.

Also, please add the tag "WinForms". You really need it.

1 solution

With the below work around code, you can achieve it:

private void chidWinButton_Click(object sender, EventArgs e)     
this.WindowState = FormWindowState.Minimized;         
this.ShowInTaskbar = false;         
new Form2().ShowDialog(this);         
this.WindowState = FormWindowState.Normal;         
this.ShowInTaskbar = true;     
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