Some times we need to store the settings of our forms to get it when we restart our application
In MS VS 2005 , there is a simple way to do that by using the Settings File
you will find this file in Properties Folder in Our Solution
you can store bool,strings,connection strings and a lot of other data type.
ohh before i forget
you can organize your code by storing the connection string in the settings file
and in your code call it by this way
Settings.Default.ConnectinNameThis operation is depend in to things
first the load Event of the Form for (read and Retrieve) the settings From the app.config file
by creating a simple methods like this
Settings.Default.ConnectionNameInSettingsFile
but before that you need to add this namespace
using YourProjectName.Properties;
Now the Real Used of This Feature:
we need to store a string for our text and when we run the application again retrieve the stored value
In Save settings button click Event
call this function
SaveSettings();
which contains this codes:
void SaveSettings()
{
//Settings Name Example Like mytextBoxstring
Settings.Default.mytextBoxstring=textbox1.text.tostring();
// Important to catch the new value
Settings.Default.Save();
}
ok the data now when you press the save button is stored in the app.config File
to retrieve this value
we need to write some code in the load Event of the Form
textbox1.text=Settings.Default.mytextBoxstring ;
you can also retrive the old values of your settings file by using this code
Settings.Default.Reset();
that’s all thing
Hints : Dont Use this Feature to store a large data and say no need to database !!!
ready for any Quastion