Control.Select 方法

定义

激活控件。Activates a control.

重载

Select(Boolean, Boolean)

激活子控件。Activates a child control. 还可以指定从中选择控件的 Tab 键顺序的方向。Optionally specifies the direction in the tab order to select the control from.

Select()

激活控件。Activates the control.

注解

如果控件的 ControlStyles.Selectable 样式位设置为 true,则 Select 方法会激活控件,该控件包含在另一个控件中,并且其所有父控件都可见且已启用。The Select method activates the control if the control's ControlStyles.Selectable style bit is set to true, it is contained in another control, and all its parent controls are both visible and enabled.

以下列表中的 Windows 窗体控件不可选择。The Windows Forms controls in the following list are not selectable. 从列表中的控件派生的控件也将无法选择。Controls derived from controls in the list will also not be selectable.

Select(Boolean, Boolean)

激活子控件。Activates a child control. 还可以指定从中选择控件的 Tab 键顺序的方向。Optionally specifies the direction in the tab order to select the control from.

protected:
 virtual void Select(bool directed, bool forward);
protected virtual void Select (bool directed, bool forward);
abstract member Select : bool * bool -> unit
override this.Select : bool * bool -> unit
Protected Overridable Sub Select (directed As Boolean, forward As Boolean)

参数

directed
Boolean

如果指定要选择的控件的方向,则为 true;否则为 falsetrue to specify the direction of the control to select; otherwise, false.

forward
Boolean

如果为 true 则在 Tab 键顺序中前移;如果为 false 则在 Tab 键顺序中后移。true to move forward in the tab order; false to move backward in the tab order.

注解

容器样式控件使用 directedforward 参数。The directed and forward parameters are used by container-style controls. 如果 directed 参数设置为 true,则将计算 forward 参数以确定要选择的控件。When the directed parameter is set to true, the forward parameter is evaluated to determine which control to select. forward 设置为 true时,选择 tab 键顺序中的下一个控件;false时,选择 tab 键顺序中的上一个控件。When forward is set to true, the next control in the tab order is selected; when false, the previous control in the tab order is selected.

另请参阅

Select()

激活控件。Activates the control.

public:
 void Select();
public void Select ();
member this.Select : unit -> unit
Public Sub Select ()

示例

下面的代码示例选择指定的 Control (如果可选)。The following code example selects the specified Control, if it is selectable.

public:
   void ControlSelect( Control^ control )
   {
      
      // Select the control, if it can be selected.
      if ( control->CanSelect )
      {
         control->Select(  );
      }
   }
public void ControlSelect(Control control)
{
   // Select the control, if it can be selected.
   if(control.CanSelect)
   {
      control.Select();
   }
}
Public Sub ControlSelect(control As Control)
   ' Select the control, if it can be selected.
   If control.CanSelect Then
      control.Select()
   End If
End Sub

另请参阅

适用于