C # winform close button

Source: Internet
Author: User

Previously, C # was used as the web, and C # was not used as the winform. In the past few days, a household financial management system was created, and the system still had certain availability, however, when processing the close button that comes with the form window, whether I use the close () method or the Resource Recycling method, the ghost cannot be closed, the result is closed using this method. Similar to closing a thread, it should be good. Wow Haha ~

 1     ///     <Summary>  
2 /// Closed button in the Main Window
3 /// </Summary>
4 /// <Param name = "sender"> </param>
5 /// <Param name = "E"> </param>
6   Private Void Mainform_formclosing ( Object Sender, formclosingeventargs E)
7 {
8 Dialogresult result;
9 Result = MessageBox. Show ( " Are you sure you want to exit? " , " Exit " , Messageboxbuttons. okcancel, messageboxicon. Question );
10 If (Result = Dialogresult. OK)
11 {
12 Application. exitthread ();
13 }
14 Else
15 {
16 E. Cancel = True ;
17 }
18 }

The formclosing event of form is added here, but it cannot be done before... Sorry, it is probably because it is too different. Haha record it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.