Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging buttons' and pictureboxes' BackColor on all forms
    primarykey
    data
    text
    <p>In my application I have got an option to customise display a bit. Basically, now it is about changing buttons' and pictureboxes' images, changing form icons etc. As you can see in the code I provided bellow. So, in this case, I have done this by simply loading a bunch of resources (images) and then when I change theme: </p> <pre><code>if (Properties.Settings.Default.Theme == "Purple") { foreach (var form in Application.OpenForms.Cast&lt;Form&gt;()) { form.Icon = Properties.Resources.Purple; } Main f1 = (Main)Application.OpenForms["Main"]; Settings f2 = (Settings)Application.OpenForms["Settings"]; f1.btn_Exit.Image = Properties.Resources.EXIT_purple; f2.btn_SaveSettings.Image = Properties.Resources.SaveSettings_purple; f1.pictureBox1.Image = Properties.Resources.Preview_purple; } </code></pre> <p>This dramatically increases the size of the application, so I came up with changing BackColor instead of loading another images. I have tried to solve this in the following way:</p> <pre><code>if (Properties.Settings.Default.Theme == "Purple") { foreach (var form in Application.OpenForms.Cast&lt;Form&gt;()) { form.Icon = Properties.Resources.Purple; } Main f1 = (Main)Application.OpenForms["Main"]; Settings f2 = (Settings)Application.OpenForms["Settings"]; f1.btn_Exit.BackColor = Color.FromArgb(164, 57, 226); f2.btn_SaveSettings.BackColor = Color.FromArgb(164, 57, 226); f2.pictureBox1.BackColor = Color.FromArgb(164, 57, 226); } </code></pre> <p>So, form icon should be changed on all running forms and I have managed to successfully do so, but when it comes to buttons and pictureboxes, I am not seeing any results, that is buttons and pictureboxes are simply not changing. Besides form icons, I should change <code>btn_Exit</code> located on the <code>Main</code> form, <code>btn_SaveSettings</code> located on the <code>Settings</code> form, and <code>pictureBox1</code> located on the <code>Settings</code> form as well. </p> <p>How can I solve this issue?</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.
 

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