You might want to use User Settings. They’re different from Application Settings because they can be read and write between different sessions of the same applications.
You can create a new setting at design time:
- Solution Explorer > Properties
- Double-click on the .settings file (this creates a new set in the default settings).
- Set name and type of your settings, plus an initial value in the value form. The scope is “user”;
At this point, assuming you created a
mySetting1 setting of
int type, you load this value in the textbox
int myValue = myNamespace.Properties.Settings.Default.mySetting1; myTextBox1.Text = myValue.ToString();
When closing the form, be sure to save the new value (I assume you checked for integrity):
int myvalue = int.Parse(myTextBox1.Text); myNamespace.Properties.Settings.Default.mySetting1 = myValue; myNamespace.Properties.Settings.Default.Save();
More of this on MSDN.