Condividi tramite


Form.TopMost Proprietà

Definizione

Ottiene o imposta un valore che indica se la maschera deve essere visualizzata come maschera superiore.

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

Valore della proprietà

true per visualizzare la maschera come forma superiore; in caso contrario, false. Il valore predefinito è false.

Esempio

Nell'esempio seguente viene illustrato come creare un form in alto. Nell'esempio vengono create due forme, una ingrandita e una che verrà visualizzata come forma superiore. Il primo modulo, denominato bottomForm, viene visualizzato ingrandita, usando la WindowState proprietà , per illustrare meglio le capacità del modulo più in alto. La seconda maschera, denominata topMostForm, imposta la TopMost proprietà su true per visualizzare la maschera come maschera superiore. Quando questo codice viene eseguito, facendo clic sul modulo ingrandita non verrà visualizzato il modulo in alto sotto il modulo ingrandita. L'esempio richiede che il metodo definito nell'esempio venga chiamato da un altro modulo.

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

Commenti

Un form in alto è un modulo che si sovrappone a tutti gli altri moduli (non superiore) anche se non è attivo o in primo piano. I moduli più in alto vengono sempre visualizzati al punto più alto nell'ordine z delle finestre sul desktop. È possibile utilizzare questa proprietà per creare un modulo sempre visualizzato nell'applicazione, ad esempio una finestra degli strumenti Trova e sostituisci.

Si applica a

Vedi anche