To achieve the requirement, you can refer to the following steps:

1.Click "Project" and choose "Setting Properties…", then choose "Settings".

Winform使用Settings保留数据

2.Add new setting in "Settings"

Winform使用Settings保留数据

3.Try the following code:

private void Accept_Click(object sender, EventArgs e)
{
    Properties.Settings.Default.cb = checkBox1.Checked;
    Properties.Settings.Default.str = textBox1.Text;
    Properties.Settings.Default.Save();
}

private void LoadSetting_Click(object sender, EventArgs e)
{
    checkBox1.Checked = Properties.Settings.Default.cb;
    textBox1.Text = Properties.Settings.Default.str;
}

private void Cancel_Click(object sender, EventArgs e)
{
    Properties.Settings.Default.cb = false;
    Properties.Settings.Default.str = "";
    Properties.Settings.Default.Save();
}

Result:

Winform使用Settings保留数据

相关文章:

  • 2021-04-01
  • 2021-12-15
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2021-05-22
猜你喜欢
  • 2021-06-17
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-08-18
  • 2022-12-23
相关资源
相似解决方案