代码之家  ›  专栏  ›  技术社区  ›  c00000fd

如果父窗口是最上面的,如何将子窗口显示为最上面的?

  •  0
  • c00000fd  · 技术社区  · 3 年前

    我正在努力确保弹出窗口显示如下:

    ChildWnd wnd = new ChildWnd();
    wnd.ShowDialog();
    

    如果父窗口也是最顶层的,则也是最顶层。

    为什么我不能这样做?

    partial class ChildWnd : Form
    {
        public ChildWnd()
        {
            InitializeComponent();
    
            this.TopMost = this.Parent.TopMost;     //Why can't I use this?
        }
    }
    
    0 回复  |  直到 3 年前