Form.TopLevel Form.TopLevel Form.TopLevel Form.TopLevel Property

Definición

Obtiene o establece un valor que indica si el formulario debe mostrarse como ventana de nivel superior.Gets or sets a value indicating whether to display the form as a top-level window.

public:
 property bool TopLevel { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool TopLevel { get; set; }
member this.TopLevel : bool with get, set
Public Property TopLevel As Boolean

Valor de propiedad

Es true para mostrar el formulario como ventana de nivel superior; en caso contrario, es false.true to display the form as a top-level window; otherwise, false. De manera predeterminada, es true.The default is true.

Excepciones

Un formulario MDI (interfaz de múltiples documentos) principal tiene que ser una ventana de nivel superior.A Multiple-document interface (MDI) parent form must be a top-level window.

Ejemplos

El siguiente código de ejemplo, use el Modal propiedad para determinar si se muestra un formulario como formulario modal.The following code example use the Modal property to determine if a form is displayed as a modal form. Si no es el FormBorderStyle y TopLevel se cambian las propiedades para que el formulario de forma que no son de nivel superior con un borde de ventana de herramientas.If it is not the FormBorderStyle and TopLevel properties are changed to make the form non-top-level form with a tool window border.

private:
   void ShowMyNonModalForm()
   {
      Form^ myForm = gcnew Form;
      myForm->Text = "My Form";
      myForm->SetBounds( 10, 10, 200, 200 );
      myForm->Show();

      // Determine if the form is modal.
      if ( myForm->Modal == false )
      {
         // Change borderstyle and make it not a top level window.
         myForm->FormBorderStyle = ::FormBorderStyle::FixedToolWindow;
         myForm->TopLevel = false;
      }
   }
private void ShowMyNonModalForm()
{
	Form myForm = new Form();
	myForm.Text = "My Form";
	myForm.SetBounds(10,10,200,200);

	myForm.Show();
	// Determine if the form is modal.
	if(myForm.Modal == false)
	{
		// Change borderstyle and make it not a top level window.
		myForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
		myForm.TopLevel = false;
	}
}
Private Sub ShowMyNonModalForm()
    Dim myForm As New Form()
    myForm.Text = "My Form"
    myForm.SetBounds(10, 10, 200, 200)

    myForm.Show()
    ' Determine if the form is modal.
    If myForm.Modal = False Then
        ' Change borderstyle and make it not a top level window.
        myForm.FormBorderStyle = FormBorderStyle.FixedToolWindow
        myForm.TopLevel = False
    End If
End Sub

Comentarios

Un formulario de nivel superior es una ventana que no tiene ningún formulario primario o cuyo formulario principal es la ventana del escritorio.A top-level form is a window that has no parent form, or whose parent form is the desktop window. Ventanas de nivel superior se suelen usar como el formulario principal en una aplicación.Top-level windows are typically used as the main form in an application.

Se aplica a

Consulte también: