I have a test app with multiple forms, one being a crude kind of menu. When I select one of the other forms with a button click the menu form minimises. All good.
What I want to happen now is when I have finished with the second form and click the red cross I want the menu to open back up from the tray. Seems simple but Im pulling my hair out.
private void Form2_Closing(object sender,System.ComponentModel.CancelEventArgs e)
{
var menu = FormControl.MainMenu;
menu.WindowState = FormWindowState.Normal;
e.Cancel = false;
}
FormControl is my class to ensure only one instance of MainMenu can be opened. The code works inside the button click event but I am unable to get any kind of form closed/closing event to trigger.
ok, your comment about “Windowstate may not work in that particular event” disturbed me so I made simple test:
Button1 Click event handler:
Form2 FormClosed event handler:
Result:
After program launches – opens Form1. After clicking button – Form1 minimizes and Form2 pops up. After closing Form2 – Form1 restores to normal state.
Resume:
double check if your Form2 REALY suscribed to FormClosed or FormClosing event.