项目中有一个主窗体MainForm ,并直接在属性中设置IsMdiContainer = true;
在MainForm窗体上放置一个按钮Button1,点击Button1弹出子窗体Form2,
并且在显示Form2之前设置Form2的MdiParent属性值为Mainform窗体。运行后 点击MainForm窗体上的Button1按钮,弹出Form2,。但是Form2窗体总是显示在Button2的后面,如何让Form2显示在最前面?效果如图:
在MainForm窗体上放置一个按钮Button1,点击Button1弹出子窗体Form2,
并且在显示Form2之前设置Form2的MdiParent属性值为Mainform窗体。运行后 点击MainForm窗体上的Button1按钮,弹出Form2,。但是Form2窗体总是显示在Button2的后面,如何让Form2显示在最前面?效果如图:
解决方案 »
- C#问题
- 双击txt文档如何用自己的记事本程序打开
- Dictionary结构中的key 不能重复,需要一个数据结构, 其中的 key 值可以重复,该使用什么数据类型呢?
- 如何在tab的CheckedChanged切换时检查数据是否保存?我需要未保存停留在原页面
- 如何读多个combobox和textbox,形成字符串?
- 如果利用反射将数据写入指定EXCEL文件的单元格?
- C#中如何创建带文本格式的outlook 2003邮件项
- 如何使bitmap图片的背景透明???
- winform 热点 动态添加热点信息
- 购物车的问题
- 从数据库读取图片,设为窗体背景,报“内存不足”?
- 如何正确使用using Word=Microsoft.Office.Interop.Word;?
Form2 frm=new Form2();
frm.MdiParent = this;
frm.TopMost = true; //加上这句
topMostForm.Show();
public static extern int SetParent(int hWndChild, int hWndNewParent);//temp2是你的子form
temp2.MdiParent = this;
temp2.Show();
SetParent((int)temp2.Handle, (int)this.Handle);
frm.Show();