初始化控件panel大小和相对父容器居中

/// <summary>
        /// 初始化界面大小
        /// </summary>
        protected void InitForm()
        {
            int winwith = Screen.PrimaryScreen.Bounds.Width;//获取显示器宽像素
            int winheight = Screen.PrimaryScreen.Bounds.Height;//获取显示器高像素
            
            this.panelPageMain.Width = winwith - 100;//减去固定模块的宽
            this.panelPageMain.Height = winheight - 200;//减去固定模块的高
            //this.panelPageMain.BackColor = Color.Red;
            Point p = new Point(50, 25);//根据实际情况自行调整
            this.panelPageMain.Location = p;

        }

 

posted @ 2020-09-18 13:30  小了白了兔666  阅读(270)  评论(0编辑  收藏  举报