我的程序在全屏的时候按钮会偏一边。我现在希望全屏的时候要按钮居中,就是用坐标算做好还能实现全屏时可以设计按钮见的距离就最好啦,谢谢!非常!!

解决方案 »

  1.   

    好几年没用C#了,写起来有点慢:namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        int mLeft = 0;  // 记录初始化时候的位置
            int mTop = 0;
            private void Form1_SizeChanged(object sender, EventArgs e)
            {
                if (WindowState == FormWindowState.Maximized)
                {
                    button1.Left = (this.Width + button1.Width) / 2;
                    button1.Top = (this.Height + button1.Height) / 2;
                }
                else
                {
                    button1.Left = mLeft;
                    button1.Top = mTop;
                }
            }        private void Form1_Load(object sender, EventArgs e)
            {
                mLeft = button1.Left;
                mTop = button1.Top;
            }
        }
    }