Winform的一些不知道啥东西

1、在Button控件上有一个属性CausesValidattion属性,可以用来设定点击Button控件的时候是否触发界面上其他控件的验证事件,但是如果Button控件在单独的一个Panel控件中

不管这个属性设置为true或者false,点击Button控件时都会触发界面上其他控件的验证事件。

2、运行Winform程序的时候,让主界面立即出现而不是等到主界面的OnLoad方法执行完才出现。可以将主界面WindowState属性设置成Maximized或者采用异步模式,将加载放到另外一个线程中

3、窗体上的CancelButton属性用来设定当按下Esc键时触发的按钮事件。

4、打开的窗体上默认选中的控件为tabindex最小的那一个。也可以使用select方法。

5、一般的窗体,点击右上角的关闭时,不会触发验证事件,但是主界面点击右上角关闭时会触发验证控件,为啥?

6、右下角显示图标notifyicon

        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ShowMain();
            }        

        }
        /// <summary>
        /// 显示主界面
        /// </summary>
        private void ShowMain()
        {
            this.Visible = true;
            this.ShowInTaskbar = true;
            this.WindowState = FormWindowState.Normal;
        }

        private void OnFormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)//当用户点击窗体右上角X按钮或(Alt + F4)时 发生           
            {
                e.Cancel = true;
                this.ShowInTaskbar = false;
                this.Visible=false;
            }        

        }

  

原文地址:https://www.cnblogs.com/chunchengwuchu/p/3426548.html