RT

解决方案 »

  1.   

    通过SetWindowPos函数
    有些语言直接有属性的
      

  2.   

    set True value to the "TopMost" property of the form.
      

  3.   

    通过设置窗体的topmost 属性可以实现
      

  4.   

    下面的示例演示了如何创建最顶级的窗体。该示例创建两个窗体,一个是最大化窗体,另一个将显示为最顶级的窗体。第一个窗体 bottomForm 使用 WindowState 属性最大化显示以更好地演示最顶级的窗体的功能。第二个窗体 topMostForm 将 TopMost 属性设置为 true 以将窗体显示为最顶级的窗体。当这段代码运行时,单击最大化窗体不会导致最顶级的窗体显示在最大化窗体的下面。该示例假定该示例中定义的方法从另一个窗体调用。[Visual Basic] 
    Private Sub CreateMyTopMostForm()
       ' Create lower form to display.
       Dim bottomForm As New Form()
       ' Display the lower form Maximized to demonstrate effect of TopMost property.
       bottomForm.WindowState = FormWindowState.Maximized
       ' Display the bottom form.
       bottomForm.Show()
       ' Create the top most form.
       Dim topMostForm As New Form()
       ' Set the size of the form larger than the default size.
       topMostForm.Size = New Size(300, 300)
       ' Set the position of the top most form to center of screen.
       topMostForm.StartPosition = FormStartPosition.CenterScreen
       ' Display the form as top most form.
       topMostForm.TopMost = True
       topMostForm.Show()
    End Sub 'CreateMyTopMostForm[C#] 
    private void CreateMyTopMostForm()
    {
       // Create lower form to display.
       Form bottomForm = new Form();
       // Display the lower form Maximized to demonstrate effect of TopMost property.
       bottomForm.WindowState = FormWindowState.Maximized;
       // Display the bottom form.
       bottomForm.Show();
       // Create the top most form.
       Form topMostForm = new Form();
       // Set the size of the form larger than the default size.
       topMostForm.Size = new Size(300,300);
       // Set the position of the top most form to center of screen.
       topMostForm.StartPosition = FormStartPosition.CenterScreen;
       // Display the form as top most form.
       topMostForm.TopMost = true;
       topMostForm.Show();
    }