Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made a simple app with 2 buttons. So when i press button 1 i change the button backcolor from red to green and the same for the second button. my question is how can i save the button backcolor statment when i close the app.
I tryied with the save settings but i fail.

What I have tried:

C#
private void button1_Click(object sender, EventArgs e)
       {
           button1.BackColor = Color.LightGreen;
           button2.BackColor = Color.LightCoral;
       }
private void button2_Click(object sender, EventArgs e)
       {
           button2.BackColor = Color.LightGreen;
           button1.BackColor = Color.LightCoral;
       }
Posted
Updated 9-Feb-21 23:03pm
v2

See answer here: c# - How can I save application settings in a Windows Forms application? - Stack Overflow[^]

Note when you select Application scope the settings will be read-only, so don't select this.

Another interesting idea is to save the form settings on application exit, see this CodeProject article: Windows Forms User Settings in C#[^]
 
Share this answer
 
v3
Comments
Maciej Los 10-Feb-21 5:05am    
5ed!
Take a look here: Save and restore your form size and location[^]
This tip is about restoring form size, but you can use similar way to restore button back color.

Good luck!
 
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