如何设置子窗口显示在父窗口的位置 如何设置子窗口显示在父窗口的中间,还有如果子窗口的宽度或高度大于父窗口如何设置子窗口的大小自动适应父窗口大小? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 子窗口 pChildWin,父窗口pParentWinRECT rect;pChildWin-> GetWindowRect(&rect);pParentWin-> ScreenToClient(&rect); Form2 form = new Form2(); form.MdiParent = this; form.Parent = splitContainer1.Panel2;form.Left =(this.splitContainer1.Panel2.Width-form.Width) / 2;form.Top = (this.splitContainer1.Panel2.Height - form.Height) / 2;this.splitContainer1.Panel2.Controls.Add(form); form.Show(); StartPosition Location = 写了个简单的实现,还有一些情况没有考虑,LZ可以试着自己修改一下public partial class Form1 : Form { public Form1() { InitializeComponent(); } private Form m_ChildForm; protected override void OnLoad(EventArgs e) { base.OnLoad(e); m_ChildForm = new Form(); m_ChildForm.MdiParent = this; ChangeChildFromSize(); m_ChildForm.Show(); ChangeChildFormLocation(); } protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); if (m_ChildForm == null) return; ChangeChildFromSize(); ChangeChildFormLocation(); } private void ChangeChildFromSize() { if (m_ChildForm.Width > this.ClientSize.Width) m_ChildForm.Width = this.ClientSize.Width; if (m_ChildForm.Height > this.ClientSize.Height) m_ChildForm.Height = this.ClientSize.Height; } private void ChangeChildFormLocation() { m_ChildForm.Location = new Point( (this.ClientSize.Width - m_ChildForm.Width) / 2, (this.ClientSize.Height - m_ChildForm.Height) / 2 ); } C#,focus()方法 方法死活点不出了. C# Winform Checkbox如何加入只讀屬性 MDI 子窗体与主窗体statusstriplabel 怎样声明数据库的连接? C#的项目有没有这样的功能 子窗口控件移除后调试起来任然存在问题 从Delphi转入.Net,遇到了第一个问题,望大家热情帮助 在 DataGrid 中,如何根据不同的值(true / false)在字段中显示不同的图片? 在C#中表示本身窗体用什么? 这是什么异常,为什么读到这个字段时出问题了 想做个dataGridView删除选中的行,想了好久没有解决.高手指点一下
pChildWin-> GetWindowRect(&rect);
pParentWin-> ScreenToClient(&rect);
form.MdiParent = this;
form.Parent = splitContainer1.Panel2;
form.Left =(this.splitContainer1.Panel2.Width-form.Width) / 2;
form.Top = (this.splitContainer1.Panel2.Height - form.Height) / 2;
this.splitContainer1.Panel2.Controls.Add(form);
form.Show(); StartPosition
Location =
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private Form m_ChildForm; protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
m_ChildForm = new Form();
m_ChildForm.MdiParent = this; ChangeChildFromSize(); m_ChildForm.Show(); ChangeChildFormLocation();
} protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
if (m_ChildForm == null)
return; ChangeChildFromSize();
ChangeChildFormLocation();
} private void ChangeChildFromSize()
{
if (m_ChildForm.Width > this.ClientSize.Width)
m_ChildForm.Width = this.ClientSize.Width;
if (m_ChildForm.Height > this.ClientSize.Height)
m_ChildForm.Height = this.ClientSize.Height;
} private void ChangeChildFormLocation()
{
m_ChildForm.Location = new Point(
(this.ClientSize.Width - m_ChildForm.Width) / 2,
(this.ClientSize.Height - m_ChildForm.Height) / 2
);
}