다음을 통해 공유


CheckBox.CheckAlign 속성

CheckBox 컨트롤에 있는 확인 표시의 가로 및 세로 맞춤을 가져오거나 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<BindableAttribute(True)> _
<LocalizableAttribute(True)> _
Public Property CheckAlign As ContentAlignment
‘사용 방법
Dim instance As CheckBox
Dim value As ContentAlignment

value = instance.CheckAlign

instance.CheckAlign = value
[BindableAttribute(true)] 
[LocalizableAttribute(true)] 
public ContentAlignment CheckAlign { get; set; }
[BindableAttribute(true)] 
[LocalizableAttribute(true)] 
public:
property ContentAlignment CheckAlign {
    ContentAlignment get ();
    void set (ContentAlignment value);
}
/** @property */
public ContentAlignment get_CheckAlign ()

/** @property */
public void set_CheckAlign (ContentAlignment value)
public function get CheckAlign () : ContentAlignment

public function set CheckAlign (value : ContentAlignment)

속성 값

ContentAlignment 값 중 하나입니다. 기본값은 MiddleLeft입니다.

예외

예외 형식 조건

InvalidEnumArgumentException

할당된 값이 ContentAlignment 열거형 값이 아닌 경우

예제

다음 코드 예제에서는 세 개의 속성 값을 한 레이블에 표시합니다. 컨트롤을 클릭할 때마다 ThreeState 속성은 true 또는 false로 변경되며 CheckAlignContentAlignmentMiddleRight 또는 MiddleLeft 값으로 변경됩니다. 다음 예제에서는 ThreeState 속성이 변경되고 컨트롤을 선택하면 속성 값이 어떻게 변경되는지 보여 줍니다. 이 예제에서는 CheckBox, LabelButton이 폼에서 모두 인스턴스화되었고, 레이블에 세 줄의 텍스트와 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
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;
    }
 }
 
private:
   void AdjustMyCheckBoxProperties()
   {
      // Concatenate the property values together on three lines.
      label1->Text = String::Format( "ThreeState: {0}\nChecked: {1}\nCheckState: {2}",
         checkBox1->ThreeState, checkBox1->Checked, 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;
      }
   }
private void AdjustMyCheckBoxProperties()
{
    // Concatenate the property values together on three lines.
    label1.set_Text("ThreeState: " + checkBox1.get_ThreeState() + "\n"
        + "Checked: " + checkBox1.get_Checked() + "\n" 
        + "CheckState: " + checkBox1.get_CheckState());

    //Change the ThreeState and CheckAlign properties on every other click.
    if (!(checkBox1.get_ThreeState())) {
        checkBox1.set_ThreeState(true);
        checkBox1.set_CheckAlign(ContentAlignment.MiddleRight);
    }
    else {
        checkBox1.set_ThreeState(false);
        checkBox1.set_CheckAlign(ContentAlignment.MiddleLeft);
    }
} //AdjustMyCheckBoxProperties
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 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에서 지원

참고 항목

참조

CheckBox 클래스
CheckBox 멤버
System.Windows.Forms 네임스페이스
ButtonBase.TextAlign 속성
ContentAlignment