Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So for my program I'm allowing the Users to customize the color of everything in the program so I made this function that does it.
and saves the Users settings.
But whenever the program Restarts for it to work like that, it doesn't work any help?
C#
SeaInject.Properties.Settings.Default.Color = this.colorDialog1.Color;
SeaProject.Properties.Settings.Default.Save();
this.metroButton1.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroButton2.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroButton3.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroButton4.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroButton5.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroButton6.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroButton7.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroButton8.BackColor = SeaProject.Properties.Settings.Default.Color;
this.metroComboBox1.BackColor = SeaProject.Properties.Settings.Default.Color;
Application.Restart();


What I have tried:

Setting the Setting as a Application setting but it made it read only.
tryed "base.Refresh();"
Posted
Updated 5-Nov-16 19:42pm
Comments
[no name] 5-Nov-16 15:35pm    
Are we supposed to guess what "not working" means? Show the code where you are reading the settings back in and tell us what the actual problem is.
Michael_Davies 5-Nov-16 16:42pm    
You seem to store the colour setting in SeaInject then tell SeaProject to save, ought it to be SeaInject that saves?
RickZeeland 5-Nov-16 16:57pm    
What happens if you comment out the Application.Restart() and start the program manually ? Does that work ?

1 solution

Application.Restart() will restart the application from defaults in the DLL files and all your in-memory changes will be invalidated.

Try saving your default color to a config file and setting the colors on startup.
 
Share this answer
 

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