Hey! I am not trying to push my luck here but I have another c# question. I have tried every possible event I found using google. Here is the code:
private void Form1_OnClose() { MessageBox.Show('I was closed -2'); } private void Form1_Exit(object sender, EventArgs evArgs) { MessageBox.Show('I was closed -1'); } private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { MessageBox.Show('I was closed 0'); } private void Form1_Closed(object sender, EventArgs e) { MessageBox.Show('I was closed 1'); } private void Form1_FormClosed(Object sender, FormClosedEventArgs e) { MessageBox.Show('I was closed 2'); }
Not one of these trigger anything when I either do Alt+f4 or click on the X button. What am I doing wrong here?
You might be missing actual subscription code, which is something along these lines:
Instead, try overriding OnXXX methods – this is the preferred way of doing things.