How can I change and save the back color in a C# Windows Application so that when I close the application and run the program again the new color will be the back color default?
Remove the background colorGo to Design > Page Color. Select No Color.
Description. The Background Color information is stored for image and photo files that have a color specified for the image background. The background color is, in most cases, displayed in the form of an RGB triplet or a hexadecimal code.
Select the word or paragraph that you want to apply shading to. On the Home tab, in the Paragraph group, click the arrow next to Shading. Under Theme Colors, click the color that you want to use to shade your selection.
On the other hand, if you're using Word 2013 or an even newer version of Word, navigate to the Design tab in Word's toolbar. Click on Page Color in the Page Background section. Locate and click on the color you want the color of the document's background changed to.
You can get that going with very little effort. Select the form in the designer, in the Properties window open the ApplicationSettings node. Select (PropertyBinding) and click the button. Select BackColor in the popup dialog. Click the dropdown arrow and click New. Set the name to, say, "FormBackColor".
The only other thing you need is an option to let the user pick another color. Very easy to do with the ColorDialog class:
private void OptionChangeColor_Click(object sender, EventArgs e) {
using (var dlg = new ColorDialog()) {
if (dlg.ShowDialog() == DialogResult.OK) {
this.BackColor = Properties.Settings.Default.FormBackColor = dlg.Color;
Properties.Settings.Default.Save();
}
}
}
You'll need to save the new color in some file that you load on startup and apply as the background color.
Or use a user setting like this.
You could do something simple like File.WriteAllText("bg.txt", this.BackColor.ToString()); and when the app loads do this.BackColor = Color.FromName(File.ReadAllText("bg.txt"));
Of course storing this color in Isolated Storage or in the registry might be better. But you get the idea...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With