Control.TabIndex Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define a ordem de tabulação do controlo dentro do seu contentor.
public:
property int TabIndex { int get(); void set(int value); };
public int TabIndex { get; set; }
member this.TabIndex : int with get, set
Public Property TabIndex As Integer
Valor de Propriedade
O valor do índice do controlo dentro do conjunto de controlos dentro do seu contentor. Os controlos no contentor estão incluídos na ordem de tabulação.
Exemplos
O seguinte exemplo de código adiciona a Button a a a a um formulário e define algumas das suas propriedades comuns. O exemplo ancora o botão no canto inferior direito do formulário para que mantenha a sua posição relativa à medida que o formulário é redimensionado. De seguida, define o BackgroundImage e redimensiona o botão para o mesmo tamanho que o Image. O exemplo então define o TabStop para true e define a TabIndex propriedade. Por fim, adiciona um gestor de eventos para gerir o Click evento do botão. Este exemplo exige que tenha um ImageList .imageList1
// 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 = gcnew Button;
// Anchor the button to the bottom right corner of the form
button1->Anchor = static_cast<AnchorStyles>(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 += gcnew System::EventHandler( this, &Form1::button1_Click );
// Add the button to the form.
this->Controls->Add( button1 );
}
// 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);
}
' Add a button to a form and set some of its common properties.
Private Sub AddMyButton()
' Create a button and add it to the form.
Dim button1 As New Button()
' Anchor the button to the bottom right corner of the form
button1.Anchor = AnchorStyles.Bottom Or 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.
AddHandler button1.Click, AddressOf Me.button1_Click
' Add the button to the form.
Me.Controls.Add(button1)
End Sub
Observações
Um índice tab pode consistir em qualquer inteiro válido maior ou igual a zero, sendo os números mais baixos mais antigos na ordem de tabulação. Se mais do que um controlo no mesmo controlo pai tiverem o mesmo índice de tabulação, a ordem z dos controlos determina a ordem a alternar entre os controlos.
Para que um controlo seja incluído na ordem de tabulação, a sua TabStop propriedade deve ser definida para true.