Click here to Skip to main content
15,903,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to save some setting of a widows form application in a file. I add a settingfile to solution but it not work. always load the default value. how can I change the default value in the setting file?
Posted

Use Settings.Save Method. Have a look here: http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx[^]

Sample:
C#
Properties.Settings.Default.backgroundColor = Color.White;
Properties.Settings.Default.Save();



Cheers!
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 8-Feb-11 17:21pm    
As simple as that, my 5,
--SA
Manfred Rudolf Bihy 8-Feb-11 17:27pm    
This is strange, I can't see any votes on this answer. :)
Sergey Alexandrovich Kryukov 8-Feb-11 19:22pm    
So many answers are ignored... somehow I spotted this question and your answer (and later fixed my mistake, posted the vote I forgot. That also happens to many commenters :-).
--SA
JOAT-MON 8-Feb-11 18:03pm    
The radio button is accepting the selection, but it is not triggering the vote.
fjdiewornncalwe 8-Feb-11 18:24pm    
+5. Nice and clean.
Hi,

Assuming you are asking @ changing the default value at run time....

In C#

Open the <your setting file name>.Designer.cs. Look for the setting property. If is has only get option add the set option

set
{
this["<your setting name>"] = value;
}

Then you can set the value from your form

Properties.<your setting file name>.Default.<your setting name> = "Your new value";

Properties.<your setting file name>.Default.Save();

Now calling the setting...

Properties.<your setting file name>.Default.<your setting name>;

which will have the new value.

Note: your setting file name = the settings file name without the .settings extension
and this settings file should be in the properties folder.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900