Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have label which Back color is set by any selected color from color dialogue box.
I want to save last changed color as default color while closing the application.
When next time I will open application,this will show last saved color.
How can I do it??
Posted
Comments
Sarita S 16-Apr-15 4:42am    
How to persist label back color while closing application??
[no name] 16-Apr-15 4:56am    
What's wrong with the answer given?
Sarita S 16-Apr-15 4:59am    
I used below link but could not persist the last value saved??
My code snap is.
Properties.Settings.Default["GridColor"] = selectedColorFromColorDialogue;
label1.BackColor = Properties.Settings.Default.GridColor;
Properties.Settings.Default.Save();
[no name] 16-Apr-15 5:04am    
So you have spent all of 9 minutes trying to solve the problem and you're back here. Good luck.
Sarita S 16-Apr-15 5:10am    
No I used this link before posting question also.I tried to solve problem by reading all related post.but no luck

1 solution

This article explains how to persist user settings:
Windows Forms User Settings in C#[^][^]
 
Share this answer
 
Comments
Sarita S 16-Apr-15 4:29am    
having this error while I used above example
Error 1 The type 'Graph.Properties.Settings' already contains a definition for 'defaultInstance' D:\CurrentGraph\GraphApplication\Properties\Settings1.Designer.cs 18 33 GraphApplication
TheRealSteveJudge 16-Apr-15 4:40am    
Your question was answered.

For a new problem please ask a new question
and provide as much information as possible. e.g. code snippets
Sarita S 16-Apr-15 4:56am    
Properties.Settings.Default["GridColor"] = selectedColorFromColorDialogue;
label1.BackColor = Properties.Settings.Default.GridColor;
Properties.Settings.Default.Save();

GridCOlor name within setting tab.
Used above code still could not save the setting
Sarita S 16-Apr-15 7:00am    
Thank it work.
TheRealSteveJudge 16-Apr-15 7:37am    
I am glad that it works now!
Thank you for accepting the solution.

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