首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

子窗体随主窗体一起放大缩小疑点

2012-06-09 
子窗体随主窗体一起放大缩小问题主窗体打开时有几个子窗体,怎么样使子窗体随主窗体一起放大缩小?[解决办法

子窗体随主窗体一起放大缩小问题
主窗体打开时有几个子窗体,怎么样使子窗体随主窗体一起放大缩小?

[解决办法]
调整大小的时候给子窗体的宽和高乘个系数就行
[解决办法]
当主窗体大小发生变化时,获取当前打开的子窗体,然后按照比例,分别付给各个子窗体的高和宽。
最好是给子窗体设置个最小值,也就是到那个时候就不发生变化了。这样有时候就不那么难看了。
[解决办法]

C# code
 private void Form1_SizeChanged(object sender, EventArgs e)        {            //Form2 subform = new Form2();            if (this.WindowState == FormWindowState.Maximized)            {                foreach (Form obj in this.MdiChildren)                {                    obj.WindowState = FormWindowState.Maximized;                    obj.Show();                }             }         }实现了,测过
[解决办法]
C# code
        private void main_SizeChanged(object sender, EventArgs e)        {            foreach (Form obj in this.MdiChildren)            {                obj.WindowState = FormWindowState.Minimized;                obj.Show();            }            if (this.WindowState == FormWindowState.Minimized)            {                this.cmsNinSystemShow.Enabled = true;                this.cmsNinSystemHide.Enabled = false;                this.ShowInTaskbar = false;            }            else            {                this.cmsNinSystemShow.Enabled = false;                this.cmsNinSystemHide.Enabled = true;                this.ShowInTaskbar = true;            }        }
[解决办法]
C# code
        bool isno = false;//控制是否第一次改变。因为第一次打开主窗体里就会执行Resize事件        int IntoHeight, IntoWidth;//放入每次改变时的父窗体值        float TempHeight, TempWidth;//获得每次放大放小的比例值        private void main_Load(object sender, EventArgs e)        {            isno = true;            IntoHeight = this.Height; IntoWidth = this.Width;        }        private void main_Resize(object sender, EventArgs e)        {            if (isno)            {                TempHeight = float.Parse(this.Height.ToString()) / float.Parse(this.IntoHeight.ToString());                TempWidth = float.Parse(this.Width.ToString()) / float.Parse(this.IntoWidth.ToString());                IntoHeight = this.Height; IntoWidth = this.Width;                ChangAllChildRenSize();            }        }        public void ChangAllChildRenSize()        {            foreach (Form tempChildForm in this.MdiChildren)            {                tempChildForm.Height = int.Parse(Convert.ToString(Math.Round(tempChildForm.Height * TempHeight,0)));                tempChildForm.Width = int.Parse(Convert.ToString(Math.Round(tempChildForm.Width * TempWidth,0)));            }        } 

热点排行