我以爲Reset()方法再次使用默認值重新設置設置,但它似乎不是。我如何使用默認值重新加載它們?爲什麼ApplicationSettingsBase.Reset()會清空PropertyValues?
private void buttonLoadDefaultSettings_Click(object sender, EventArgs e)
{
FooSettings.Default.Reset();
// Data grid will show an empty grid after call to reset.
DataGridFoo.Rows.Clear();
foreach (SettingsPropertyValue spv in FooSettings.Default.PropertyValues)
{
DataGridFoo.Rows.Add(spv.Name, spv.PropertyValue);
}
}
更新
private void buttonLoadDefaultSettings_Click(object sender, EventArgs e)
{
foreach (SettingsProperty sp in FooSettings.Default.Properties)
{
FooSettings.Default[sp.Name.ToString()] = sp.DefaultValue;
}
DataGridFoo.Rows.Clear();
foreach (SettingsPropertyValue spv in FooSettings.Default.PropertyValues)
{
DataGridFoo.Rows.Add(spv.Name, spv.PropertyValue);
}
}
刪除調用復位()和手動設置的屬性值的默認存儲的。我仍然渴望聽到它是否應該被使用,或者我錯過了什麼?