CheckBox.AutoCheck 属性

定义

获取或设置一个值,该值指示当单击某一 Checked 时,CheckStateCheckBox 的值以及该 CheckBox 的外观是否自动改变。

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

属性值

如果 Checked 值或 CheckState 值及该控件的外观在发生 Click 事件时自动更改,则为 true;否则为 false。 默认值是 true

示例

下面的代码示例创建并初始化 一个 CheckBox,为它提供切换按钮的外观,将 设置为 AutoCheckfalse,并将其添加到 。Form

public:
   void InstantiateMyCheckBox()
   {
      // Create and initialize a CheckBox.   
      CheckBox^ checkBox1 = gcnew CheckBox;
      
      // Make the check box control appear as a toggle button.
      checkBox1->Appearance = Appearance::Button;
      
      // Turn off the update of the display on the click of the control.
      checkBox1->AutoCheck = false;
      
      // Add the check box control to the form.
      this->Controls->Add( checkBox1 );
   }
public void InstantiateMyCheckBox()
 {
    // Create and initialize a CheckBox.   
    CheckBox checkBox1 = new CheckBox(); 
    
    // Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button;
 
    // Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = false;
 
    // Add the check box control to the form.
    Controls.Add(checkBox1);
 }
Public Sub InstantiateMyCheckBox()
    ' Create and initialize a CheckBox.   
    Dim checkBox1 As New CheckBox()
    
    ' Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button
    
    ' Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = False
    
    ' Add the check box control to the form.
    Controls.Add(checkBox1)
End Sub

注解

如果 AutoCheck 设置为 false,则需要添加代码以更新Checked事件处理程序中的 ClickCheckState 值。

适用于