Espandi Riduci a icona
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
Traduzione
Originale
Questo argomento non è stato ancora valutato - Valuta questo argomento

Proprietà Control.Top

Ottiene o imposta la distanza in pixel tra il bordo superiore del controllo e il bordo superiore dell'area client del contenitore.

Spazio dei nomi:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[BrowsableAttribute(false)]
public int Top { get; set; }

Valore proprietà

Tipo: System.Int32
Oggetto Int32 che rappresenta la distanza in pixel tra il bordo inferiore del controllo e il bordo superiore dell'area client del contenitore.

Il valore della proprietà Top è equivalente alla proprietà Point.Y del valore della proprietà Location del controllo.

Le modifiche apportate ai valori delle proprietà Height e Top comportano la modifica del valore della proprietà Bottom del controllo.

Nell'esempio di codice riportato di seguito vengono creati tre controlli Button in un form e vengono impostate le dimensioni e la posizione di ciascun controllo utilizzando le proprietà relative al dimensionamento e al posizionamento. Per eseguire questo esempio è necessario che sia disponibile un oggetto Form con una larghezza e un'altezza di almeno 300 pixel.


// Create three buttons and place them on a form using 
// several size and location related properties. 
private void AddOKCancelButtons()
{
   // Set the button size and location using 
   // the Size and Location properties.
   Button buttonOK = new Button();
   buttonOK.Location = new Point(136,248);
   buttonOK.Size = new Size(75,25);
   // Set the Text property and make the 
   // button the form's default button. 
   buttonOK.Text = "&OK";
   this.AcceptButton = buttonOK;

   // Set the button size and location using the Top, 
   // Left, Width, and Height properties.
   Button buttonCancel = new Button();
   buttonCancel.Top = buttonOK.Top;
   buttonCancel.Left = buttonOK.Right + 5;
   buttonCancel.Width = buttonOK.Width;
   buttonCancel.Height = buttonOK.Height;
   // Set the Text property and make the 
   // button the form's cancel button.
   buttonCancel.Text = "&Cancel";
   this.CancelButton = buttonCancel;

   // Set the button size and location using 
   // the Bounds property.
   Button buttonHelp = new Button();
   buttonHelp.Bounds = new Rectangle(10,10, 75, 25);
   // Set the Text property of the button.
   buttonHelp.Text = "&Help";

   // Add the buttons to the form.
   this.Controls.AddRange(new Control[] {buttonOK, buttonCancel, buttonHelp} );
}


.NET Framework

Supportato in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supportato in: 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
Il documento è risultato utile?
(1500 caratteri rimanenti)

Aggiunte alla community

AGGIUNGI
© 2013 Microsoft. Tutti i diritti riservati.