C#.net - 当MDI Parent中有一些控件时,如何将MDI子窗体带到前面 [英] C#.net - How to bring a MDI child form to the front when MDI Parent has some controls in it

查看:188
本文介绍了C#.net - 当MDI Parent中有一些控件时,如何将MDI子窗体带到前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- 当MDI Parent中有一些控件时,如何将MDI子窗体带到前面



我创建了一个 MDI Parent包含Split Container& amp;树形视图控件,当我尝试打开一个窗体(MDI子)时,该窗体在拆分容器后面打开。有人可以解释如何设置这个权利。



如果这是使用控件类 - MDICLIENT ...我们现在如何表示代表子表单的客户端控件的确切数量。

Ex:



以下代码中我们不知道 i 的价值



- How to bring a MDI child form to the front when MDI Parent has some controls in it

I have created a "MDI Parent" form containing a Split Container & Tree View Controls, when i try to open a Form (MDI Child), that form opens behind the Split Container. Could some one please explain how to set this right.

If this is using controls class - MDICLIENT ... how do we now the exact number of the client control which represents the Child Form.
Ex:

in the following code we do not know the value for i

MdiClient mdiClient = null;

               // Get the MdiClient from the parent form.

               for (int i = 0; i < this.Controls.Count; i++)
               {
      // If the form is an MDI container, it will contain an MdiClient control

   // just as it would any other control.

                 mdiClient = this.Controls[i] as MdiClient;
                   if (mdiClient != null)
                   {
                       // The MdiClient control was found.

                     // MessageBox.Show("name "+mdiClient.ToString());

                       //
                       mdiClient.BringToFront();

                       break;
                   }
               }

推荐答案

MDI父表单不应该对其进行任何控制,不包括状态条形码或菜单栏等.MDI儿童被吸引到MDI父母的控件后面。



如果这是一个新软件,考虑转移到SDI接口,因为MDI实际上已被弃用很久以前。对于新用户,SDI比具有不同限制的MDI更方便和熟悉的界面。
MDI parent form should not have any controls on it excluding status bar or menu bar etc. MDI children are drawn behind the controls on MDI parent.

Also if this is a new software consider moving to SDI interface since MDI is deprecated actually a long time ago. For new users SDI is more convenient and familiar interface than the MDI which has different kinds of limitations.


这是有问题的,因为MDI父级不是为托管任何控件而设计的。此控件(您可以使用原始Windows API访问)称为MDI客户端,它占用MDI父级的整个客户端区域,仅用于托管MDI子级。我记得甚至在这个表面上绘制一些背景图像的问题也很困难。



所以,这是我的建议:停止折磨自己并用这个来吓跑你的用户烂UI设计。甚至微软也会采取措施来阻止它。它被排除在WPF之外,并且可能只保留在Forms中以便与legacy兼容。你有没有看到任何至少是专业的MDI用户界面?哪有这回事。没有它,您可以更轻松地实现设计,质量更好。我会告诉你该怎么做。



请参阅:

http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [ ^ ],

关于在WPF中使用MDI窗口的问题 [ ^ ],

MDIContainer给出错误 [ ^ ],

如何在WPF中创建MDI父窗口? [ ^ ],

如何设置最大化的子表单,最后的子表单最小化 [ ^ ]。



祝你好运,

-SA
This is problematic because the MDI parent is not designed to host any controls except one. This control (which you can access using raw Windows API) is so called MDI client, it takes the whole client area of the MDI parent and is only designed to host MDI children. I remember that even the problem of drawing some background image on this surface was difficult.

So, here is my advice: stop torturing yourself and scare off your users with this rotten UI design. Even Microsoft does what it takes to discourage it. It is excluded from WPF and probably kept in Forms just for compatibility with legacy. Did you ever see any MDI UI which is at least professional? There is no such thing. You can do much easier to implement design without it, with much better quality. I''ll give you an idea on what to do.

Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to Create MDI Parent Window in WPF?[^],
How to set child forms maximized, last childform minimized[^].

Good luck,
—SA


我有这个也是问题,这是我用来处理它的代码。



公共部分类frmBeam:表格

{

frmMain FormMain;

frmBeamControl FormBeamControl;



private void frmBeam_Click(object sender,EventArgs e)

{

FormBeamControl = new frmBeamControl();

FormBeamControl.Show();

this.FormBeamControl.TopMost = true;

}



}
I had this issue too and this is the code I used to handle it.

public partial class frmBeam : Form
{
frmMain FormMain;
frmBeamControl FormBeamControl;

private void frmBeam_Click(object sender, EventArgs e)
{
FormBeamControl = new frmBeamControl();
FormBeamControl.Show();
this.FormBeamControl.TopMost = true;
}

}


这篇关于C#.net - 当MDI Parent中有一些控件时,如何将MDI子窗体带到前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆