You have to check the radio button selection in both the radio button check change event and need to un-check the other one first. Have a look here
private void rbOne_CheckedChanged(object sender, EventArgs e)
{
if (rbTwo.Checked)
{
// make it uncheck and remove the red rectangle
}
{
if (rbOne.Checked)
{
status = rbOne.Text;
buff.write(Color.Red, status);
}
}
private void rbTwo_CheckedChanged(object sender, EventArgs e)
{
if (rbOne.Checked)
{
// make it uncheck and remove the blue rectangle
}
if (rbTwo.Checked)
{
status = rbTwo.Text;
buff.write(Color.Blue, status);
}
}
or either you can check the radio button checked property first for each of them if one is checked then don't create another rectangle.