C#中子窗体如何覆盖在父窗体容器中的所有控件上

2025-05-12 02:06:17
推荐回答(4个)
回答1:

using System.Runtime.InteropServices;

 [DllImport("user32")]
 public static extern int SetParent(int hWndChild, int hWndNewParent);

 调用:

   Form2 f2 = new Form2();
   f2.MdiParent = this;
   f2.Show();
   SetParent((int)f2.Handle, (int)this.Handle);

 

上两位说的 TopMost 是错误的,题主自己试验即可。

回答2:

上楼正解,设置窗体的属性TopMost为True,则该窗体将会置顶。

回答3:

可是这个函数要怎么实现呀

回答4:

设置窗体置顶TopMost