コントロールがクリックされると、コントロールの Checked 値と外観が自動的に変わるかどうかを示す値を取得または設定します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
'宣言
Public Property AutoCheck As Boolean
'使用
Dim instance As RadioButton
Dim value As Boolean
value = instance.AutoCheck
instance.AutoCheck = value
public bool AutoCheck { get; set; }
public:
property bool AutoCheck {
bool get ();
void set (bool value);
}
/** @property */
public boolean get_AutoCheck ()
/** @property */
public void set_AutoCheck (boolean value)
public function get AutoCheck () : boolean
public function set AutoCheck (value : boolean)
プロパティ値
Click イベントが発生したときに、コントロールの Checked 値と外観が自動的に変わる場合は true。それ以外の場合は false。既定値は true です。
解説
Checked 値が false に設定されている場合、コントロールの RadioButton の部分は Click イベント ハンドラのコードでチェックする必要があります。また、RadioButton が RadioButton コントロール グループに属している場合は、このプロパティを設定すると、グループ内で 1 度に 1 つのコントロールだけがチェックされます。
AutoCheck プロパティを false に設定した場合、RadioButton コントロールのグループは、一度に 1 つの項目しか選択できないグループとしては機能しなくなり、Checked プロパティはコードで更新する必要があります。
使用例
RadioButton を作成および初期化し、トグル コントロールのような外観にするコード例を次に示します。AutoCheck プロパティを false に設定して、ボタンを Form に追加します。
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
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 void InitializeMyRadioButton()
{
// Create and initialize a new RadioButton.
RadioButton radioButton1 = new RadioButton();
// Make the radio button control appear as a toggle button.
radioButton1.set_Appearance(Appearance.Button);
// Turn off the update of the display on the click of the control.
radioButton1.set_AutoCheck(false);
// Add the radio button to the form.
get_Controls().Add(radioButton1);
} //InitializeMyRadioButton
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, 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