In my C# WinForms program I have some forms and I show one of them as a dialog:

MyForm mf = new MyForm();
mf.ShowDialog();

But when I try to assigne a form closing event for them, it is not working;

mf.FormClosing += delegate { MessageBox.Show("Dialog is closed.")};

What is the problem?

P.S: It works fine when I call the form using mf.Show() method.

Thanks.

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top