Control.TabStop Proprietà

Definizione

Ottiene o imposta un valore che indica se l'utente può assegnare lo stato attivo al controllo con TAB.

C#
public bool TabStop { get; set; }

Valore della proprietà

true se l'utente può assegnare lo stato attivo al controllo con TAB; in caso contrario, false. Il valore predefinito è true.

Nota: questa proprietà restituirà true sempre per un'istanza della Form classe.

Esempio

L'esempio di codice seguente aggiunge un oggetto Button a un modulo e imposta alcune delle relative proprietà comuni. Nell'esempio viene ancorato il pulsante all'angolo in basso a destra del modulo in modo da mantenere la relativa posizione relativa quando il modulo viene ridimensionato. Imposta quindi il BackgroundImage pulsante e ridimensiona la stessa dimensione dell'oggetto Image. L'esempio imposta quindi su TabStoptrue e imposta la TabIndex proprietà. Infine, aggiunge un gestore eventi per gestire l'evento Click del pulsante. In questo esempio è necessario che sia presente un ImageList oggetto denominato imageList1.

C#
// Add a button to a form and set some of its common properties.
private void AddMyButton()
{
   // Create a button and add it to the form.
   Button button1 = new Button();

   // Anchor the button to the bottom right corner of the form
   button1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);

   // Assign a background image.
   button1.BackgroundImage = imageList1.Images[0];

   // Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center;
   
   // Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size;

   // Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1;
   button1.TabStop = true;

   // Add a delegate to handle the Click event.
   button1.Click += new System.EventHandler(this.button1_Click);

   // Add the button to the form.
   this.Controls.Add(button1);
}

Commenti

Quando l'utente preme il tasto TAB, lo stato attivo di input viene impostato sul controllo successivo nell'ordine di tabulazione. I controlli con il TabStop valore della proprietà di false non sono inclusi nella raccolta di controlli nell'ordine di tabulazioni. L'ordine di tabulazioni può essere modificato impostando il valore della proprietà del TabIndex controllo.

Si applica a

Prodotto Versioni
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Vedi anche