.net - What is the proper way to manually check and uncheck a RadioButton when the AutoCheck property is set to false in C#? -
i have set of radio buttons, , 2 of them need prompt user confirmation dialog before allowing value change. this, handle click event , set autocheck property false on each of these radio buttons. however, selected radiobuttons no longer unchecked when set check property true on clicked radiobutton. right i'm looping through controls on panel , making sure none of other radiobuttons checked, there more efficient way this? you can use variable store last checked radiobutton: //first, have set lastchecked = radiobutton1 (or of radiobuttons) radiobutton lastchecked; //click event handler used radiobuttons private void radiosclick(object sender, eventargs e) { radiobutton radio = sender radiobutton; if (radio != lastchecked){ radio.checked = true; lastchecked.checked = false; lastchecked = radio; } //else radio.checked = !radio.checked; } if want allow user uncheck radio (a strange behavior), remove // before else clause in code ...