子父类窗体中的子窗体最大化后如何定位? 比如我有个其他控件在夫窗体的左边界!如何让子窗体最大化时定位到空件的右边界? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先取出子窗体在父窗体当中的大小,再按照比例来缩放大小 /// <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; } } AxShockwaveFlash控件问题 vs 2008 打上 sp1 包出现以下错误 类型转换问题? string变量的问题 请高人解答接口作为成员变量、属性的返回值类型等问题 资源绑定的一点问题 请看下一段很简单的程序下关于内存泄露的问题? 画一个蓝色的方块,大家进来帮个忙了。 Developer XtraTreeList第三方控件问题 为什么Response语句,虽然单步调试能执行该语句,但网页上却没有弹出窗口? WinForm 菜单如何添加到treeview中? 利用反射怎样获得动态加载Form上TextBox与ComboBox中的值
先取出子窗体在父窗体当中的大小,再按照比例来缩放大小
/// <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; }
}