Note that there are some explanatory texts on larger screens.

plurals
  1. PORetaining the changes made to the backcolor property
    primarykey
    data
    text
    <p>I am developing a windows application.</p> <p>I have 3 forms:</p> <p>I want to change the backcolor of all the 3 forms to the color selected by the user.</p> <p>I have used the following code I am able to change the backcolor but When I exit the application and restart it I am not able to get the color that user has set. I am getting the default colour only.</p> <p>Is it possible to retain the colour selected by the user and use it as backcolor when the user restarts the application.</p> <p>CODE</p> <p>In Form1</p> <pre><code>ColorDialog c1 = new ColorDialog(); public static System.Drawing.Color bkc; private void button1_Click(object sender, EventArgs e) { DialogResult res = c1.ShowDialog(); if (res == DialogResult.OK) { bkc = c1.Color; this.BackColor = bkc; MessageBox.Show(Convert.ToString(bkc)); } } private void button2_Click(object sender, EventArgs e) { Form2 obj1 = new Form2(); obj1.BackColor = bkc; obj1.Show(); } </code></pre> <p>In Form 2 CODE</p> <pre><code> private void button2_Click(object sender, EventArgs e) { Form3 obj1 = new Form3(); obj1.Show(); } private void Form2_Load(object sender, EventArgs e) { this.BackColor = Form1.bkc; } </code></pre> <p>In Form3 CODE</p> <pre><code> private void button2_Click(object sender, EventArgs e) { Form1 obj1 = new Form1(); obj1.Show(); } private void Form3_Load(object sender, EventArgs e) { //Form1 obj2 = new Form1(); this.BackColor = Form1.bkc; } </code></pre> <p>In the color dialog box I am selecting a color and pressing Ok button the color is also changed but when I restart the application I dont get the colour which I set using the Color Dialog.I want to retain this setting so that the user can get the desired color without resetting it each time the application is executed.</p> <p>The above code does not generate any error.</p> <p>can anybody help me out in performing this task?</p> <p>Thanks in advance! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload