Radio Button and CheckBox
Radio Button and CheckBox: - These two controls are used when we
want, the user select the values from a list of avilabel values.
Radio Button allows single selection and CheckBox allows
multiple selections.
Note –
Because radio button allows only single selection, when we want to use them
under multiple questions, we require to group the radio buttons, that are used
under the particular question.
To group them we need to place them on different container
controls like- Panel and GroupBox etc.
- Both radio button and CheckBox controls has a property
checked, to identify whether the control has been selected or not, which
returns true if selected or else return false.
- Under Button1 click:
{
if (radioButton1.Checked)
MessageBox.Show("Radio Button 1 is Selected");
else if (radioButton2.Checked)
MessageBox.Show("Radio Button 2 is Selected");
else if (radioButton3.Checked)
MessageBox.Show("Radio Button 3 is Selected");
}
|
- Under Button2 click:
{
if (checkBox1.Checked)
MessageBox.Show("Check Box1 is selected");
if (checkBox2.Checked)
MessageBox.Show("Check Box2 is selected");
if (checkBox3.Checked)
MessageBox.Show("Check Box3 is selected");
}
|
Checked Change event: - It is the default event of both the
above two controls, which gets raised when the control is selected as well as
deselected also.
No comments:
Post a Comment