I have an application with some textboxes. My user fills the textboxes and runs some methods, when they close the application data is lost (normally).
I want to ke
Simplest way is binding your textboxes to application settings:
FormClosed event save application settingsSaving settings:
private void Form_FormClosed(object sender, FormClosedEventArgs e)
{
Settings.Default.Save();
}
Next time when user will start your application, settings will be loaded from user-specific file, and textboxes will be filled with same data as it was before user closed an application last time.
Also in application settings you can store local variables, but you will have to add settings for them manually, and manually read that setting on application start:
var x = Settings.Default.MyCounterSettings.Default.MyCounter = x just before calling Settings.Default.Save()