CheckBox

Used to take the choice from the user. The check box can be checked or un-checked by the user.

API: System.Windows.Forms.CheckBox
Naming Convension: chkxxxxxx
Check Box
Properties of CheckBox
Property Description
Name Specifies the name of the control.
Checked Represents the current status of the check box, whether it is checked or un-checked.
Text Specifies the displayable text of the control.
BackColor, ForeColor, Font, Enabled, Visible, Cursor, Size, Location, TextAlign, Image, ImageAlign, TabIndex, ContextMenuStrip

Events of CheckBox
Event Description
CheckedChanged Executes when the user checks / un-checks the checkbox.
Click, DoubleClick, MouseMove, MouseEnter, MouseLeave, KeyPress, Enter, Leave

Methods of CheckBox
Method Description
Focus() Moves the focus to the control.

Demo on CheckBox

Design
checkBox1
label1
Check Box
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
label1.Text = "The check box is checked.";
else
label1.Text = "The check box is un-checked.";
}

Demo on CheckBoxs

Design
CheckBox1:
Text: Normal
Name: btnNormal

CheckBox2:
Text: Minimize
Name: btnMinimize

CheckBox3:
Text: Maximize
Name: btnMaximize

CheckBox4:
Text: Exit
Name: btnExit


private void btnNormal_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
}
private void btnMinimize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void btnMaximize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}

Demo on CheckBoxs

Design
CheckBox1:
Text: Show Background Image
Name: btnShowBackgroundImage

CheckBox2:
Text: Clear Background Image
Name: btnClearBackgroundImage


private void btnShowBackgroundImage_Click(object sender, EventArgs e)
{
this.BackgroundImage = Image.FromFile("c:\\globe.jpg");
this.BackgroundImageLayout = ImageLayout.Zoom;
}
private void btnClearBackgroundImage_Click(object sender, EventArgs e)
{
this.BackgroundImage = null;
}