按下Close,X,按钮时,不会调用OnClosing事件.Windows Mobile

4 c# windows-mobile

我是Windows Mobile的新用户,并创建了一个应用程序,需要在表单关闭时进行一些清理.当我单击ControlBox中的Close时,它不会调用OnClosing事件.这在常规窗口中工作正常,但不能与我的Windows Mobile设备一起使用.

这是我的代码:

protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
...
}
Run Code Online (Sandbox Code Playgroud)

我也试过这个没有运气:

Form.Closing += new System.ComponentModel.CancelEventHandler(WindBaseForm_Closing);
Run Code Online (Sandbox Code Playgroud)

我很感激你能给予的任何帮助.

cta*_*cke 9

正确.Windows Mobile中的(X)按钮称为"智能最小化"按钮,仅最小化窗体.将Form的MinimizeBox属性设置为false,它将更改为(OK),这将关闭Form(并引发事件).

有关为何发生这种情况的详细信息,请阅读此内容.