Windows
CheckBox を表します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class CheckBox
Inherits ButtonBase
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
public class CheckBox : ButtonBase
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
public ref class CheckBox : public ButtonBase
/** @attribute ComVisibleAttribute(true) */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
public class CheckBox extends ButtonBase
ComVisibleAttribute(true)
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
public class CheckBox extends ButtonBase
CheckBox を使用すると、ユーザーに true/false、yes/no などのオプションを提示できます。CheckBox コントロールは、イメージ、テキスト、またはその両方を表示できます。
CheckBox コントロールと RadioButton コントロールには似た機能があり、ユーザーがオプションのリストから選択できるようにします。CheckBox コントロールは、複数のオプションを組み合わせて選択できるようにします。これに対して RadioButton コントロールは、複数のオプションから 1 つだけを選択できるようにします。
Appearance プロパティは、CheckBox を通常のCheckBox で表示するのか、またはボタンで表示するのかを決定します。
ThreeState プロパティは、コントロールで 2 ステートと 3 ステートのどちらをサポートするのかを決定します。Checked プロパティは、2 ステートのCheckBox コントロールの値を取得または設定するために使用し、CheckState プロパティは、3 ステートのCheckBox コントロールの値を取得または設定するために使用します。
メモ |
|---|
| ThreeState プロパティが true に設定されている場合、Checked プロパティは、チェックされた状態と中間状態のどちらであるかを示す true を返します。 |
FlatStyle プロパティは、コントロールのスタイルと外観を決定します。FlatStyle プロパティが FlatStyle.System に設定されている場合は、ユーザーが使用しているオペレーティング システムによってコントロールの外観が決定されます。
中間状態とは、次のような状態です。RichTextBox で選択したテキストを太字にするかどうかを決定する CheckBox があるとします。テキストを選択して CheckBox をクリックすると、選択したテキストが太字になります。同様に、テキストを選択すると、選択したテキストが太字かどうかが CheckBox に表示されます。選択したテキストに太字と標準の両方のテキストがある場合、CheckBox は中間状態となります。
CheckBox を作成および初期化し、その外観をトグル ボタンにするコード例を次に示します。さらに、AutoCheck を false に設定し、トグル ボタンを Form に追加します。
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 'InstantiateMyCheckBox
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:
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.set_Appearance(Appearance.Button);
// Turn off the update of the display on the click of the control.
checkBox1.set_AutoCheck(false);
// Add the check box control to the form.
get_Controls().Add(checkBox1);
} //InstantiateMyCheckBox
public function InstantiateMyCheckBox()
{
// Create and initialize a CheckBox.
var checkBox1 : CheckBox = 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);
}
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ButtonBase
System.Windows.Forms.CheckBox
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
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、1.0