Question : Maximize Parent Form After Closing The Child

Hello guys,
I have a main form and almost all others are it's children. When I create a child form like that:
childForm child = new childForm();
child.Show();
this.Hide();
I hide the parent form on the system tray. But after I close the child form, it's stupid for the main form to stay in the tray. And another thing. For example i open a form and from the second i open a secon generation child form. After closing it I don't want the main form to show.
Is there a way to solve this problem without using that:
http://forum.codecall.net/c-programming/515-c-calling-parent-functions-child-form.html
?

Answer : Maximize Parent Form After Closing The Child

You can just subscribe to the FormClosed() event of "childForm" and show the main form again from there:

        private void button1_Click(object sender, EventArgs e)
        {
            childForm child = new childForm();
            child.Show();
            child.FormClosed += new FormClosedEventHandler(child_FormClosed);
            this.Hide();
        }

        void child_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Show();
        }

Another option is to use ShowDialog():

        private void button1_Click(object sender, EventArgs e)
        {
            childForm child = new childForm();
            this.Hide();
            child.ShowDialog();
            this.Show();
        }
Random Solutions  
 
programming4us programming4us