日期:2014-05-18  浏览次数:20956 次

c#.net 画面调整
我用的是c#.net2005环境,我想实现画面随着大小的变化按钮的位置也随之调整,设置了antosize为false abort的属性也设置了但还是实现不了,那位高手指点指点?

------解决方案--------------------
Dock属性你试试,最好用到panel。ANCHOR也可以
------解决方案--------------------
Anchor全选上,看看能不能停靠住
------解决方案--------------------
C# code
#region//窗口大小改变
        float x=0;
        float y=0;

        private void Frm_Resize_1(object sender, System.EventArgs e)

------解决方案--------------------
位置怎么调整, 是相对位移不变,还是上下左右的坐标的比例不变,如果是前者则用Anchor属性,若为后者,则用代码吧,下面是代码:


C# code
        private void TestFormResizeEvent_Resize(object sender, EventArgs e)
        {
            int width = this.Width;
            int height = this.Height;

            int x = (int)(this.Width * this.leftPercent);//leftPercent和topPercent是根据初始化的坐标位置算出来的与宽、高的比例
            int y = (int)(this.Height * this.topPercent);

            this.btnTest.Location = new System.Drawing.Point(x, y);
        }