日期:2014-05-17  浏览次数:20770 次

控件 分辨率 自动变化
界面:
左上一个panel 里面是几个label 和text 
右上一个panel 里面是一个label和一个dataview
下面一个panel 里面是几个label text button 还有一个dataview
最下面几个button

当前屏幕分辨率 1600*900
当我设置800*600后 程序运行显示不完整,窗体设置自动最大化了,但是控件没有反应

后来改用代码:也无效
 private void ctlAppearance_position(int Width, int Height)
        {
            Form2 frm = new Form2();               
                foreach (Control control in (frm.Controls))
                {
                    float a = control.Width * Width / 1600;
                    float b = control.Height *Height/900 ;

                    control.Scale(new SizeF(control.Width / Width,control.Height / Height));
                }
            
        }
        //载入初始化
        private void Form2_Load(object sender, EventArgs e)
        {
            Rectangle rect = new Rectangle();//声明一个rect
            rect = Screen.PrimaryScreen.Bounds;//获取当前屏幕的分辨率
            int width, height;//声明宽度,高度
            width = int.Parse(rect.Width.ToString());
            height = int.Parse(rect.Height.ToString());//将高度宽度赋值
            ctlAppearance_position(Width, Height);

求解 怎么达到要求,改代码  还是界面设置控件?控件属性我设置了很多都无效,求详细步骤
------解决方案--------------------
设置Anchor属性和Dock属性,或者使用tableLayoutPanel控件来布局
------解决方案--------------------
1楼正解。。