• Windows Form窗体的关闭按钮的启用与否


    public partial class Form1 : Form
        {
            private bool isEnableCloseButton = false;
            public Form1(string strFlag)
            {
                InitializeComponent();
                if (strFlag == "no")
                {
                    this.lbl_CloseButtonIsEnabled.Text = "窗体右上角关闭按钮无效";
                    this.isEnableCloseButton = false;
                }
                else
                {
                    this.lbl_CloseButtonIsEnabled.Text = "可以通过窗体右上角关闭按钮 关闭窗体";
                    this.isEnableCloseButton = true;
                }
            }

            protected override CreateParams CreateParams
            {
                get
                {
                    if (isEnableCloseButton)
                    {
                        CreateParams parameters = base.CreateParams;
                        return parameters;
                    }
                    else
                    {
          int CS_NOCLOSE = 0x200;
                        CreateParams parameters = base.CreateParams;
                        parameters.ClassStyle |= CS_NOCLOSE;
                        return parameters;                   
                    }
                }
            }
    }

    //调用显示该窗体
    Form1 frm = new Form1("no");
    frm.ShowDialog();

  • 相关阅读:
    C#8.0新特性
    C#7.0新特性
    C#6.0新特性
    C#6.0到C#8.0的新特性
    纪念博客开通的6月29日
    什么是开发中经常说的'POCO'
    什么时候用Model,什么时候用Entity?
    C#数组的 Length 和 Count()
    C#中foreach的实现原理
    Windows Server 2012 R2远程桌面默认端口修改
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1266220.html
Copyright © 2020-2023  润新知