C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Next: You can add event handlers and change properties by right-clicking on the CheckBox and selecting Properties.
C# program that uses CheckState and Checked properties
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Acquire the state of the CheckBox.
CheckState state = checkBox1.CheckState;
// Demonstrate how the CheckBox can be switched upon.
switch (state)
{
case CheckState.Checked:
case CheckState.Indeterminate:
case CheckState.Unchecked:
{
MessageBox.Show(state.ToString());
break;
}
}
// Tell if the box is checked.
MessageBox.Show(checkBox1.Checked.ToString());
}
}
}
Next: In this screenshot, we see what the CheckBox looks like when I changed the CheckAlign property, and also the FlatStyle property.
PropertyReview: We described various properties of the CheckBox, which may be useful for planning some programming tasks.