チェック ボックス コントロールの水平または垂直の配置を取得または設定します。
Public Property CheckAlign As ContentAlignment
[C#]
public ContentAlignment CheckAlign {get; set;}
[C++]
public: __property ContentAlignment get_CheckAlign();public: __property void set_CheckAlign(ContentAlignment);
[JScript]
public function get CheckAlign() : ContentAlignment;public function set CheckAlign(ContentAlignment);
プロパティ値
ContentAlignment 値の 1 つ。既定値は MiddleLeft です。
例外
例外の種類 | 条件 |
---|---|
InvalidEnumArgumentException | 代入された値が、 ContentAlignment 列挙値ではありません。 |
使用例
次のコード例では、ラベル内の 3 つのプロパティの値を示します。 ThreeState プロパティは、ボタンをクリックするごとに、 true と false の間で切り替わります。 CheckAlign は、 MiddleRight と MiddleLeft の間で切り替わります。この例では、 ThreeState プロパティが変更され、ボタンがチェックされた場合に、プロパティ値がどのように変化するかを示します。このコードは、 CheckBox 、 Label 、 Button がフォーム上ですべてインスタンス化されていること、および 3 行のテキストと System.Drawing 名前空間への参照をラベルに表示できることを前提にしています。このコードは、ボタンの Click イベント ハンドラで呼び出す必要があります。
Private Sub AdjustMyCheckBoxProperties()
' Concatenate the property values together on three lines.
label1.Text = "ThreeState: " & checkBox1.ThreeState.ToString() & ControlChars.Cr & _
"Checked: " & checkBox1.Checked.ToString() & ControlChars.Cr & _
"CheckState: " & checkBox1.CheckState.ToString()
' Change the ThreeState and CheckAlign properties on every other click.
If Not checkBox1.ThreeState Then
checkBox1.ThreeState = True
checkBox1.CheckAlign = ContentAlignment.MiddleRight
Else
checkBox1.ThreeState = False
checkBox1.CheckAlign = ContentAlignment.MiddleLeft
End If
End Sub 'AdjustMyCheckBoxProperties
[C#]
private void AdjustMyCheckBoxProperties()
{
// Concatenate the property values together on three lines.
label1.Text = "ThreeState: " + checkBox1.ThreeState.ToString() + "\n" +
"Checked: " + checkBox1.Checked.ToString() + "\n" +
"CheckState: " + checkBox1.CheckState.ToString();
// Change the ThreeState and CheckAlign properties on every other click.
if (!checkBox1.ThreeState)
{
checkBox1.ThreeState = true;
checkBox1.CheckAlign = ContentAlignment.MiddleRight;
}
else
{
checkBox1.ThreeState = false;
checkBox1.CheckAlign = ContentAlignment.MiddleLeft;
}
}
[C++]
private:
void AdjustMyCheckBoxProperties()
{
// Concatenate the property values together on three lines.
label1->Text = String::Format( S"ThreeState: {0}\nChecked: {1}\nCheckState: {2}",
__box(checkBox1->ThreeState), __box(checkBox1->Checked), __box(checkBox1->CheckState));
// Change the ThreeState and CheckAlign properties on every other click.
if (!checkBox1->ThreeState)
{
checkBox1->ThreeState = true;
checkBox1->CheckAlign = ContentAlignment::MiddleRight;
}
else
{
checkBox1->ThreeState = false;
checkBox1->CheckAlign = ContentAlignment::MiddleLeft;
}
}
[JScript]
private function AdjustMyCheckBoxProperties()
{
// Concatenate the property values together on three lines.
label1.Text = "ThreeState: " + checkBox1.ThreeState.ToString() + "\n" +
"Checked: " + checkBox1.Checked.ToString() + "\n" +
"CheckState: " + checkBox1.CheckState.ToString();
// Change the ThreeState and CheckAlign properties on every other click.
if (!checkBox1.ThreeState)
{
checkBox1.ThreeState = true;
checkBox1.CheckAlign = ContentAlignment.MiddleRight;
}
else
{
checkBox1.ThreeState = false;
checkBox1.CheckAlign = ContentAlignment.MiddleLeft;
}
}
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
CheckBox クラス | CheckBox メンバ | System.Windows.Forms 名前空間 | TextAlign