将 mdi 子项放在 mdi 父对象的前面 [英] Bring mdi child infront of mdi parent objects
问题描述
我正在 Visual Studio 2012 中处理 Windows 应用程序表单,在那里我被困在 UI 设计部分.实际上,我试图在所有控件对象(面板,表格布局面板)前面打开子窗体.这是父表单
I am working on a windows application form in visual studio 2012 where I am stuck in the UI design part. Actually, I am trying to open the child form in front of all the control objects (panel, table layout panel). This the parent form
这是我的 mdi 父表单中的代码
Here is the code inside my mdi parent form
frmControlAccount x;
private void controlToolStripMenuItem_Click(object sender, EventArgs e)
{
if (x == null || x.IsDisposed)//to avoid multiple opening of forms
{
x = new frmControlAccount();
x.MdiParent = this;
x.Show();
}
else
{
x.Focus();
x.BringToFront();
}
}
由于表单没有显示我也试过这个代码
Since the form was not showing I tried this code too
private void MainPage_MdiChildActivate(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
{
panel1.SendToBack();
picHomepage.SendToBack();
}
else
{
panel1.BringToFront();
picHomepage.BringToFront();
}
}
推荐答案
你不能在 MDI Parent 窗体上放置控件,因为这会使你的 MDI Parent 的工作区变小,并且 MDI Child 窗体只会在MDI 父级的客户区.
You cannot put controls on the MDI Parent form, because this will make the client area of your MDI Parent smaller, and the MDI Child form will only be visible in the Client Area of the MDI Parent.
例如,在您的 MDI 父级上放置一个面板(没有别的),并将其停靠在左侧,其值为 200.
您将看到您的 MDI 子表单将可见,但您无法将它们移到此面板上.这就是 MDI 的工作原理.
For example, put a Panel on your MDI Parent ( nothing else) and dock it left with a with of 200.
You will see that your MDI Child Forms will be visible, but you cannot move them over this panel.
That is how MDI Works.
如果你想在 MDI Parent 上显示一个图像,你可以通过在 Paint 事件中自己绘制来实现.
If you want to show an image on the MDI Parent you can do it by painting it yourself in the paint event.
这篇关于将 mdi 子项放在 mdi 父对象的前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!