示例截图:
1、建立一个专门用于获取MDI父窗体展示子窗体的区域的大小的空白窗体,在窗体Load时就实例化该窗体,但不show出来。
private void Main_Load(object sender, EventArgs e)
{
MainFormSizeFrm = new MainFormSize();
MainFormSizeFrm.MdiParent = this;
{
MainFormSizeFrm = new MainFormSize();
MainFormSizeFrm.MdiParent = this;
}
2、创建函数获取MDI父窗体展示子窗体的区域大小
/// <summary>
/// 获取MDI父窗体展示子窗体的区域大小
/// </summary>
/// <returns></returns>
private Size GetMdiAreaSize()
{
MdiClient client = MainFormSizeFrm.Parent as MdiClient;
return client.ClientSize;
}
/// 获取MDI父窗体展示子窗体的区域大小
/// </summary>
/// <returns></returns>
private Size GetMdiAreaSize()
{
MdiClient client = MainFormSizeFrm.Parent as MdiClient;
return client.ClientSize;
}
3、设置子窗体的Size
tableFrm = new Table ();
tableFrm.MdiParent = this;
tableFrm.StartPosition = FormStartPosition.CenterScreen;
tableFrm.Size = this.GetMdiClientAreaSize();
tableFrm.Show();
tableFrm.MdiParent = this;
tableFrm.StartPosition = FormStartPosition.CenterScreen;
tableFrm.Size = this.GetMdiClientAreaSize();
tableFrm.Show();