共用方式為


Control.TabStop 屬性

定義

取得或設定一個值,指示使用者是否能使用 TAB 鍵將焦點分配給此控制項。

public:
 property bool TabStop { bool get(); void set(bool value); };
public bool TabStop { get; set; }
member this.TabStop : bool with get, set
Public Property TabStop As Boolean

屬性值

true如果使用者能用 TAB 鍵將焦點轉移到控制鍵上;否則,。 false 預設值為 true

注意:這個屬性對於類別的Form實例總是會回傳true

範例

以下程式碼範例將 a Button 加入表單,並設定其一些常見屬性。 範例中將按鈕固定在表單的右下角,以保持表單調整大小時的相對位置。 接著它設定 , BackgroundImage 並將按鈕調整到和 Image. 相同的大小。 範例接著設定 到 TabStoptrue設定屬性。TabIndex 最後,它新增了一個事件處理程序來處理 Click 按鈕事件。 此範例要求你有一個 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

備註

當使用者按下 TAB 鍵時,輸入焦點會設定在 tab 順序中的下一個控制點。 屬性值 TabStop 為 的 false 控制項不會包含在制表序列中的控制項集合中。 Tab 順序可以透過設定控制項的 TabIndex 屬性值來調整。

適用於

另請參閱