Binding to a Radio Button in Windows Forms

J

jehugaleahsa

Hello:

I have radio buttons bound to boolean properties in a business object.

private void bindRadioButton(RadioButton button, string
propertyName)
{
Binding binding = button.DataBindings.Add("Checked",
exclusionBindingSource,
propertyName,
false,
DataSourceUpdateMode.OnPropertyChanged,
false);
binding.ControlUpdateMode =
ControlUpdateMode.OnPropertyChanged;
button.Enabled = exclusionBindingSource.Count > 0;
}

When I click on another radio button, the radio group is cleared
instead of checking the radio button I clicked on. I have to double
click on a radio button to switch it.

I know why this is happening: since my radio buttons are updated
automatically by the data source (i.e., my business object), when I
click off a radio button, no booleans are set. This makes the radio
button group cleared before the clicked-on radio button has a chance
to modify the business object.

Is there a way to get around this?

In time it is happening like this:

1) The ex-checked button realizes it is no longer checked.
2) The ex-checked button updates the data source.
3) The interface realizes a change in the data source and updates the
interface to clear the group.
4) The clicked-on button never gets set because the interface already
cleared the group.
5) I cry a lot and stomp my feet.

Any ideas how to get around this?

Thanks,
Travis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top