CheckBox::CheckAlign Property


Gets or sets the horizontal and vertical alignment of the check mark on a CheckBox control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

property ContentAlignment CheckAlign {
	ContentAlignment get();
	void set(ContentAlignment value);

Property Value

Type: System.Drawing::ContentAlignment

One of the ContentAlignment values. The default value is MiddleLeft.

Exception Condition

The value assigned is not one of the ContentAlignment enumeration values.

The following code example displays the values of three properties in a label. The ThreeState property alternates between true and false with alternating clicks of the control and the CheckAlign alternates between the MiddleRight and MiddleLeft values of ContentAlignment. This example shows how the property values change as the ThreeState property changes and the control is checked. This example requires that a CheckBox, Label and Button have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the System.Drawing namespace. This code should be called in the Click event handler of the control.

   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;
         checkBox1->ThreeState = false;
         checkBox1->CheckAlign = ContentAlignment::MiddleLeft;

.NET Framework
Available since 1.1
Return to top