I have a WinForms dialog box that contains 3 radio buttons. I am using ApplicationSettings to bind the Checked property of each of these RadioButton controls, but it doesn’t do what I am expecting it to do. Now I have to click each radio button twice before it gets checked and the selected radio button is not being persisted.
Is there a line of code I need to execute when the form is closed that saves the user settings?
How do I eliminate the need for 2x clicking on the radio buttons?
Is there a better way to persist this type of user setting? I do have a public property on the dialog box class that gets/sets an enum value based on which radio button is checked, but I didn’t see an easy way of binding that property to a user setting.
Edit: Should have specified that I’m using vb.net. I think that means My.Settings instead of Properties.Settings.
I can answer this part of your question:
Application settings are stored in your
Settingsclass, in thePropertiesnamespace. TheSettingsclass has a static property calledDefault, which represents the current settings for your application. So in your main form’s Closing event, you call:… to save the settings.
Likewise you can get to the settings programatically using the setting’s name:
Properties.Settings.Default.MyRadioButtonState(or whatever you’ve called it).