RadioButton.AutoCheck 屬性

定義

取得或設定值,指出當按一下控制項時,Checked 值和控制項的外觀是否自動變更。

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 值和控制項的外觀會在 Click 事件上自動變更,則為 true,否則為 false。 預設值是 true

範例

下列程式碼範例會建立和初始化 RadioButton ,提供切換控制項的外觀、將其 AutoCheck 屬性 false 設定為 ,並將它加入至 Form

private void InitializeMyRadioButton()
{
   // Create and initialize a new RadioButton.
   RadioButton radioButton1 = new RadioButton();

   // Make the radio button control appear as a toggle button.
   radioButton1.Appearance = Appearance.Button;

   // Turn off the update of the display on the click of the control.
   radioButton1.AutoCheck = false;

   // Add the radio button to the form.
   Controls.Add(radioButton1);
}
Private Sub InitializeMyRadioButton()
    ' Create and initialize a new RadioButton. 
    Dim radioButton1 As New RadioButton()
       
    ' Make the radio button control appear as a toggle button.
    radioButton1.Appearance = Appearance.Button
       
    ' Turn off the update of the display on the click of the control.
    radioButton1.AutoCheck = False
       
    ' Add the radio button to the form.
    Controls.Add(radioButton1)
End Sub

備註

Checked如果值設定 false 為 ,則必須 RadioButton 在事件處理常式的程式碼中 Click 檢查控制項的部分。 此外,如果 RadioButton 是控制項群組的一 RadioButton 部分,這個屬性可確保在指定時間只檢查其中一個控制項。

AutoCheck如果 屬性設定 false 為 ,則控制項群組不會做為互斥群組 RadioButton ,而且 Checked 屬性必須在程式碼中更新。

適用於