例如,当用户更改背景颜色时,会修改 Settings.settings 文件。它有效。
但是在用户单击“确定”后,应用程序不会更改其背景颜色。它仅在我关闭并再次构建应用程序时才有效。
如何在单击按钮时重新加载表单或用户控件?(尝试使用 .Refresh(),但它不起作用)
private void refreshSettings()
{
this.BackColor = Properties.Settings.Default.bgdColor;
this.Font = Properties.Settings.Default.fontType;
this.ForeColor = Properties.Settings.Default.fontColor;
}
private void Settings_Load(object sender, EventArgs e)
{
refreshSettings();
bgdColorLBL.BackColor = Properties.Settings.Default.bgdColor;
fontColorLBL.BackColor = Properties.Settings.Default.fontColor;
fontTypeLBL.Font = Properties.Settings.Default.fontType;
fontTypeLBL.Text = Properties.Settings.Default.fontType.Name;
}
private void okBTN_Click(object sender, EventArgs e)
{
LeagueUC lg = new LeagueUC();
InitializeComponent();
this.Close();
}
private void bgdColorLBL_Click(object sender, EventArgs e)
{
ColorDialog dlg = new ColorDialog();
dlg.Color = Properties.Settings.Default.bgdColor;
if (dlg.ShowDialog() == DialogResult.OK)
{
Properties.Settings.Default.bgdColor = dlg.Color;
Properties.Settings.Default.Save();
bgdColorLBL.BackColor = dlg.Color;
}
}