C # disable and enable the close button on Windows form

Source: Internet
Author: User

Disable and enable the close button on Windows form

 

1 public partial class form1: Form
2 {
3 private bool isenableclosebutton = false;
4 Public form1 (string strflag)
5 {
6 initializecomponent ();
7 if (strflag = "no ")
8 {
9 This. lbl_closebuttonisenabled.text = "the close button in the upper right corner of the form is invalid ";
10 This. isenableclosebutton = false;
11}
12 else
13 {
14 This. lbl_closebuttonisenabled.text = "you can close the form by clicking the close button in the upper right corner of the form ";
15 this. isenableclosebutton = true;
16}
17}
18
19 protected override createparams
20 {
21 get
22 {
23 if (isenableclosebutton)
24 {
25 createparams parameters = base. createparams;
26 return parameters;
27}
28 else
29 {
30 int cs_noclose = 0x200;
31 createparams parameters = base. createparams;
32 parameters. classstyle | = cs_noclose;
33 return parameters;
34}
35}
36}
37}

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.