Export (0) Print
Expand All

Keeping a Windows Form on Top

Visual Studio .NET 2003

With the Microsoft Windows 2000 operating system, a top-most form always stays in front of all windows in a given application. In Microsoft Windows 98, a top-most form stays in front of all windows in all applications. For example, you may want to keep a floating tool window in front of your application's main window. The TopMost property controls whether a form is a top-most form. Note that a top-most form will float above other, non–top-most forms even when it is not active.

To make a form the top-most form in a Windows Forms application at design time

  • In the Properties window, set the TopMost property to true.

To make a form the top-most form in a Windows Forms application programmatically

  • In a procedure, set the TopMost property to true.
    ' Visual Basic
    Public sub MakeOnTop()
       myTopForm.TopMost = True
    End Sub
    
    // C#
    public void MakeOnTop()
    {
       myTopForm.TopMost = true;
    }
    
    // C++
    public:
       void MakeOnTop()
       {
          myTopForm->TopMost = true;
       }
    

See Also

Introduction to Windows Forms | Creating Windows Forms | Dialog Boxes in Windows Forms

Show:
© 2014 Microsoft