C# WINFORM技巧

来源:互联网 发布:科学院院士体验知乎 编辑:程序博客网 时间:2024/05/16 04:44

①如何设置窗口的位置:

在form的load事件中设置(eg:窗口居中显示):

this.Location = new Point(
                (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2,
                (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2
                );

 

②设置窗口事件对应的处理方法(eg:shown事件的处理方法)

this.Shown += new EventHandler(doLogin);//事件委托

 private void doLogin(object sender, EventArgs e)
        {           
        }