Control.TabIndex Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar eller anger tabbordningen för kontrollen i containern.
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
Egenskapsvärde
Indexvärdet för kontrollen i uppsättningen kontroller i containern. Kontrollerna i containern ingår i tabbordningen.
Exempel
I följande kodexempel läggs ett Button till i ett formulär och några av dess gemensamma egenskaper anges. Exemplet fäster knappen i formulärets nedre högra hörn så att den behåller sin relativa position när formuläret ändras. Därefter ställer den BackgroundImage in och ändrar storlek på knappen till samma storlek som Image. Exemplet anger TabStop sedan egenskapen till true och TabIndex . Slutligen lägger den till en händelsehanterare för att hantera Click händelsen för knappen. Det här exemplet kräver att du har namnet ImageListimageList1.
// 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
Kommentarer
Ett flikindex kan bestå av ett giltigt heltal som är större än eller lika med noll, och lägre tal är tidigare i tabbordningen. Om fler än en kontroll på samma överordnade kontroll har samma flikindex, avgör z-ordningen för kontrollerna ordningen för att gå igenom kontrollerna.
För att en kontroll ska inkluderas i tabbordningen måste dess TabStop egenskap vara inställd på true.