Freigeben über


Control.TabIndex-Eigenschaft

Ruft die Aktivierreihenfolge des Steuerelements in dessen Container ab oder legt diese fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<LocalizableAttribute(True)> _
Public Property TabIndex As Integer
'Usage
Dim instance As Control
Dim value As Integer

value = instance.TabIndex

instance.TabIndex = value
[LocalizableAttribute(true)] 
public int TabIndex { get; set; }
[LocalizableAttribute(true)] 
public:
property int TabIndex {
    int get ();
    void set (int value);
}
/** @property */
public int get_TabIndex ()

/** @property */
public void set_TabIndex (int value)
public function get TabIndex () : int

public function set TabIndex (value : int)

Eigenschaftenwert

Der Indexwert des Steuerelements in einer Gruppe von Steuerelementen in dessen Container. Die Steuerelemente im Container werden in die Aktivierreihenfolge aufgenommen.

Hinweise

Ein Index der Aktivierreihenfolge kann aus jeder gültigen ganzen Zahl größer oder gleich 0 bestehen, wobei kleinere Zahlen in der Aktivierreihenfolge weiter vorne stehen. Wenn mehrere Steuerelemente des gleichen übergeordneten Steuerelements den gleichen Index der Aktivierreihenfolge haben, bestimmt die z-Reihenfolge der Steuerelemente die Reihenfolge, in der die Steuerelemente durchlaufen werden.

Damit ein Steuerelement in die Aktivierreihenfolge aufgenommen wird, muss dessen TabStop-Eigenschaft auf true festgelegt sein.

Beispiel

Im folgenden Codebeispiel wird einem Formular ein Button hinzugefügt, und es werden einige allgemeine Eigenschaften festgelegt. Im Beispiel wird die Schaltfläche in der rechten unteren Ecke des Formulars verankert, sodass sie auch dann ihre relative Position beibehält, wenn die Größe des Formulars geändert wird. Nach dem Festlegen des BackgroundImage wird die Größe der Schaltfläche auf die gleiche Größe wie das Image angepasst. Im Beispiel wird dann der TabStop auf true festgelegt. Außerdem wird die TabIndex-Eigenschaft festgelegt. Abschließend wird ein Ereignishandler hinzugefügt, um das Click-Ereignis der Schaltfläche zu behandeln. In diesem Beispiel muss ein ImageList mit der Bezeichnung imageList1 vorhanden sein.

' 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
// 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:
   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.set_Anchor(AnchorStyles.Bottom | AnchorStyles.Right);
    // Assign a background image.
    button1.set_BackgroundImage(imageList1.get_Images().get_Item(0));
    // Specify the layout style of the background image. Tile is the 
    // default.
    button1.set_BackgroundImageLayout(ImageLayout.Center);
    // Make the button the same size as the image.
    button1.set_Size(button1.get_BackgroundImage().get_Size());
    // Set the button's TabIndex and TabStop properties.
    button1.set_TabIndex(1);
    button1.set_TabStop(true);
    // Add a delegate to handle the Click event.
    button1.add_Click(new System.EventHandler(this.button1_Click));
    // Add the button to the form.
    this.get_Controls().Add(button1);
} //AddMyButton

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0

Siehe auch

Referenz

Control-Klasse
Control-Member
System.Windows.Forms-Namespace
UpdateZOrder
TabStop