Form.TopMost Form.TopMost Form.TopMost Form.TopMost Property

Definición

Obtiene o establece un valor que indica si el formulario debe mostrarse como un formulario de nivel superior.Gets or sets a value indicating whether the form should be displayed as a topmost form.

public:
 property bool TopMost { bool get(); void set(bool value); };
public bool TopMost { get; set; }
member this.TopMost : bool with get, set
Public Property TopMost As Boolean

Valor de propiedad

true para mostrar el formulario como formulario de nivel superior; de lo contrario, false.true to display the form as a topmost form; otherwise, false. De manera predeterminada, es false.The default is false.

Ejemplos

El ejemplo de código siguiente muestra cómo crear un formulario de nivel superior.The following code example demonstrates how to create a topmost form. El ejemplo crea dos formularios, uno que está maximizada y otro que se mostrará como un formulario de nivel superior.The example creates two forms, one that is maximized and one that will be displayed as a topmost form. El primer formulario denominado bottomForm, se muestra maximizada, utilizando el WindowState propiedad, para demostrar mejor las capacidades del formulario de nivel superior.The first form, named bottomForm, is displayed maximized, using the WindowState property, to better demonstrate the abilities of the topmost form. El segundo formulario denominado topMostForm, Establece la TopMost propiedad true para mostrar el formulario como formulario de nivel superior.The second form, named topMostForm, sets the TopMost property to true to display the form as a topmost form. Cuando se ejecuta este código, al hacer clic en el formulario maximizado no hará que el formulario de nivel superior se muestra debajo del formulario maximizado.When this code is run, clicking on the maximized form will not cause the topmost form to be displayed below the maximized form. El ejemplo requiere que el método definido en el ejemplo se llama desde otro formulario.The example requires that the method defined in the example is called from another form.

private:
   void CreateMyTopMostForm()
   {
      // Create lower form to display.
      Form^ bottomForm = gcnew 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 = gcnew Form;

      // Set the size of the form larger than the default size.
      topMostForm->Size = System::Drawing::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();
   }
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();
}
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

Comentarios

Formulario de nivel superior es un formulario que se superpone a todos los demás formularios (que no son de nivel superior), incluso si no es el formulario activo o de primer plano.A topmost form is a form that overlaps all the other (non-topmost) forms even if it is not the active or foreground form. Formularios de nivel superior siempre se muestran en el punto más alto en el orden z de las ventanas en el escritorio.Topmost forms are always displayed at the highest point in the z-order of the windows on the desktop. Puede utilizar esta propiedad para crear un formulario que siempre se muestra en la aplicación, como una ventana de herramientas Buscar y reemplazar.You can use this property to create a form that is always displayed in your application, such as a Find and Replace tool window.

Se aplica a

Consulte también: