I need use two radio buttons; one is ON and another is OFF.
When we click on any radio button, the application shows me both messages! How do I make it show only the message for the radio button clicked?
private void rB_OFF_CheckedChanged(object sender,EventArgs e)
{
MessageBox.Show("You clicked OFF");
}
private void rB_ON_CheckedChanged(object sender,EventArgs e)
{
MessageBox.Show("You clicked ON");
}
because, either the radioButton
turns true
or false
, it just trigger the checkedChanged
event, so you need to do this.
private void rB_OFF_CheckedChanged(object sender,EventArgs e)
{
if (rB_OFF.Checked == true)
{
MessageBox.Show("You clicked OFF");
}
}
private void rB_ON_CheckedChanged(object sender,EventArgs e)
{
if (rB_ON.Checked == true)
{
MessageBox.Show("You clicked ON");
}
}