On Windows Mobile forms, there are two buttons: "OK" and "X.
1. In form attributes, if "minimizebox = false" is set, the form is displayed with "OK". Click this button to destroy and exit the form. 2. Set "minimizebox = true ", the form displays "X" and click this button. The form is hidden but not destroyed. However, sometimes we want to destroy the form when we click the "X" button, instead of hiding the form, so how to implement it? First, when you click the "X" button, the closed method of the form is not stimulated, so we cannot destroy the form in this method, but we can implement it in another way. When you click the "X" button, the form is hidden, so the focus of the form is lost. There are two kinds of events: 1) lostfocus event; 2) deactivate event; we only need to destroy the form in the methods triggered by these two events to truly exit rather than hide the form. The implementation steps are as follows: 1) Add the following code to the form constructor: This. deactivate + = new system. eventhandler (this. form_closed); or this. lostfocus + = new system. eventhandler (this. form_closed); 2) in the Form class, add the method code: Private void form_closed (Object sender, eventargs e) {This. dispose ();} according to the above description, We can click "X" to destroy the form rather than hide the form. I hope this article will help you. This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/doubleblue/archive/2009/04/16/4083273.aspx