我是调用 public void GSize(int x,int y, int width, int height)
{ this.Size=new Size(width,height);
this.Location=new Point(x,y); }
控制窗口大小的,可是我发现他的效果变成了只显示这部分范围上的东西,不是把整个窗口按比例缩小,如果我想实现的是按比例缩小或者扩大窗口和移动窗口还应该怎么做呢

解决方案 »

  1.   

    this.Size=new Size(width,height);
    this.Location=new Point(x,y);
    仅控制窗口的大小,对窗口内的控件显示无控制作用。
    要想让窗口内控件在大小随窗口大小改变而改变,要将窗口内每一个控件的anchor属性设置为:
    Top, Bottom, Left, Right
      

  2.   

    anchor属性设置为:Top, Bottom, Left, Right也仅可以保持窗口内控件与窗口的边距保持不变。要想按比例缩小只好在窗口的SizeChange事件中自己按比例设置每一个控件的大小我边距了
      

  3.   

    private void button1_Click(object sender, EventArgs e)
            {
                //按比例调整窗口大小
                double x = this.Size.Width*0.85;
                double y = this.Size.Height * 0.85;
                this.Size = new Size((int)x, (int)y);
            }        private void Form1_SizeChanged(object sender, EventArgs e)
            {
                //按比例调整窗口内控件大小
                double x = button1.Size.Width * 0.85;
                double y = button1.Size.Height * 0.85;
                button1.Size = new Size();
                x = button1.Location.x * 0.8;
                y = button1.Location.y * 0.8;
                Location = new Point((int)x, (int)y);
            }
      

  4.   

    不好意思上面的代码中有点小错误应该如下: 
           private void Form1_SizeChanged(object sender, EventArgs e)
            {
                //按比例调整窗口内控件大小
                double x = button1.Size.Width * 0.8;
                double y = button1.Size.Height * 0.8;
                button1.Size = new Size((int)x,(int)y);
                x = button1.Location.X * 0.8;
                y = button1.Location.Y * 0.8;
                button1.Location = new Point((int)x, (int)y);
            }