Control.TabStop 属性
获取或设置一个值,该值指示用户能否使用 Tab 键将焦点放到该控件上。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Property TabStop As Boolean
用法
Dim instance As Control
Dim value As Boolean
value = instance.TabStop
instance.TabStop = value
public bool TabStop { get; set; }
public:
property bool TabStop {
bool get ();
void set (bool value);
}
/** @property */
public boolean get_TabStop ()
/** @property */
public void set_TabStop (boolean value)
public function get TabStop () : boolean
public function set TabStop (value : boolean)
属性值
如果用户可以用 Tab 键将焦点放到此控件上,则为 true;反之,则为 false。默认为 true。
提示
对于 Form 类的实例,该属性将始终返回 true。
备注
当用户按下 Tab 键时,输入焦点设置为 Tab 键顺序中的下一个控件。TabStop 属性值为 false 的控件不包括在按 Tab 键顺序排列的控件集合中。Tab 键顺序可以通过设置控件的 TabIndex 属性值来操作。
示例
下面的代码示例将 Button 添加到窗体并设置该控件的一些通用属性。示例将该按钮定位在窗体的右下角,因此调整窗体大小时其相对位置不变。接着,它设置 BackgroundImage 并将该按钮的大小调整为与 Image 同样的大小。然后,该示例将 TabStop 设置为 true,并设置 TabIndex 属性。最后,它添加一个事件处理程序以处理按钮的 Click 事件。此示例要求您有一个名为 imageList1
的 ImageList。
' 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
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0
请参见
参考
Control 类
Control 成员
System.Windows.Forms 命名空间
Control.TabIndex 属性