Search code examples
winformsdata-bindingradio-button

Winforms radio button unchecks itself when group box is disabled, BUT only when another control data bound to its checked property


If the databind in form load is commented out, this works normally. Radio buttons are disabled but, per expectation, their checked-ness does not change.

When the databind is present, radio buttons are disabled, but, counter to expectation, their checked-ness changes for no apparent reason.

The radio buttons themselves are not bound to anything, and the first one is set as checked at design time. (You can see this print the "True" debug output when the radio button is set up by InitializeComponent in the designer code.)

The intent is that the top radio button be a source for the combo box's enabled-ness. The radio buttons' checked-ness should not be affected by anything but user clicks.

screen capture


Solution

  • Taking a hint from https://stackoverflow.com/a/39139080/2112855, the answer was to change DataSourceUpdateMode.OnPropertyChanged to DataSourceUpdateMode.Never.

    My faulty intuition about the DataSourceUpdateMode setting was that it controlled radio -> combo changes ("downstream" in my mental model).

    After experimentation I found that DataSourceUpdateMode actually controlled combo -> radio changes ("upstream" in my mental model).