Hi Edsger,
In your code snippet, the Checked property of the CheckBox is set to true, but the CheckBox is unselected when the form is shows. This is because the data bound to the Checked property is false. The value from the setting(false) would overwrite the value you set in the setting load event handler(true).
When we bind a data source to the controls, we need to know that the binding source now becomes the underlying data source. So that if we want to modify the data of the control programmatically, we need to modify the data source, not the control object directly. The code snippet below show my idea:
//true: load data from setting; false: load data from shared memory.
private bool _isLoadSetting = false;
void Default_SettingsLoaded(object sender, System.Configuration.SettingsLoadedEventArgs e)
{
if (_isLoadSetting)
{
//Get data from shared memory.
Settings.Default.check1 = sharedMemory.autoExposure;
//Set other properties here.
}
else
{
//Get data from setting.
Settings.Default.Reload();
}
}
Let me know if this helps or not.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.