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
-
The error is likely that you aren't wiring the events at the right time. Check your program.cs file. It should look something like this:
using System;
using System.ComponentModel;
using System.Threading;
using System.Windows.Forms;
namespace Test
{
internal class Program
{
private static void Main(string[] args)
{
Form form = new Form2();
form.Closing += form_Closing;
Application.Run(form);
}
private static void form_Closing(object sender, CancelEventArgs e)
{
MessageBox.Show("Closing");
}
}
}
I just ran this and the event fired.
- 热议问题