Reputation: 23177
This is what I'm doing and it results in a stack overflow because it just switches back and forth forever.
private void radioButtonA_CheckedChanged(object sender, EventArgs e)
{
radioButtonB.Checked = !radioButtonB.Checked;
}
private void radioButtonB_CheckedChanged(object sender, EventArgs e)
{
radioButtonA.Checked = !radioButtonA.Checked;
}
There has to be a better way to do this...
Upvotes: 3
Views: 6299
Reputation: 41
Is it toggling of "One" radio button what you were trying to do? If so, I tried this, and it works for me:
Set the Radio Button AutoCheck property to FALSE.
Create a "Click" event for the Radio Button.
In the Click Event Handler for the Radio Button paste the code:
radioButton.Checked = !radioButton.Checked;
I hope this helps.
Upvotes: 4
Reputation: 2287
You can disable the Event in the code before changing the Checked value, then add it again immediately afterwards.
Upvotes: 1
Reputation: 9607
try commenting out all of your code and see if it works the way you want. you don't have to uncheck the other radio buttons in code
Upvotes: 4