比如我有个其他控件在夫窗体的左边界!如何让子窗体最大化时定位到空件的右边界?

解决方案 »

  1.   


      先取出子窗体在父窗体当中的大小,再按照比例来缩放大小
     /// <summary>
            /// 主窗体大小改变的时候触发的事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
           
            private void MainForm_SizeChanged(object sender, EventArgs e)
            {
                GetMainSize();//主页面最大化的时候的主界面的大小            if (_isMax == true)
                {
                    double tabMain_w = Math.Floor(0.80875 * width);//tabMain为你的窗体名称,或是控件名称
                    double tabMain_h = Math.Floor(0.72941 * height);                double LetfControl_w = Math.Floor(0.17396 * width);//LetfControl为你的窗体名称,或是控件名称                double LetfControl_h = Math.Floor(0.73088 * height);                this.tabMain.Width = (int)tabMain_w;
                    this.tabMain.Height = (int)tabMain_h;                this.leftControl2.Width = (int)LetfControl_w;
                    this.leftControl2.Height = (int)LetfControl_h;
                }            if (_isMin == true)
                {
                    double tabMain_w = Math.Floor(0.80875 * width);
                    double tabMain_h = Math.Floor(0.72941 * height);                double LetfControl_w = Math.Floor(0.17396 * width);
                    double LetfControl_h = Math.Floor(0.73088 * height);
                    this.tabMain.Width = (int)tabMain_w;
                    this.tabMain.Height = (int)tabMain_h;                this.leftControl2.Width = (int)LetfControl_w;
                    this.leftControl2.Height = (int)LetfControl_h;
                }            if (_isnomal == true)
                {
                    double tabMain_w = Math.Floor(0.82392 * width);
                    double tabMain_h = Math.Floor(0.74411 * height);                double LetfControl_w = Math.Floor(0.16478 * width);
                    double LetfControl_h = Math.Floor(0.73970 * height);                this.tabMain.Width = (int)tabMain_w;
                    this.tabMain.Height = (int)tabMain_h;                this.leftControl2.Width = (int)LetfControl_w;
                    this.leftControl2.Height = (int)LetfControl_h;
                }
            }         /// <summary>
            /// 获取第一步主页面最大化的时候的主界面的大小
            /// </summary>
            private void GetMainSize()
            {
                if(this.WindowState == FormWindowState.Maximized)
                {
                    _isMax = true;
                    width = this.ClientSize.Width;
                    height = this.ClientSize.Height;            }            if (this.WindowState == FormWindowState.Minimized)
                {
                    _isMin = true;
                    width = this.ClientSize.Width;
                    height = this.ClientSize.Height;            }
                if (this.WindowState == FormWindowState.Normal)
                {
                   _isnomal = true;
                    width = this.ClientSize.Width;
                    height = this.ClientSize.Height;            }
            }