1

I want to define a new color, and be able to use it throughout the project. Then I can change in one place and all the controls using this defined color will change.

Also it would be nice to be able to select this color from the control properties:

color selection in control properties

It's like defining a color theme in android in colors.xml.

Manish
  • 1,139
  • 7
  • 21
Figaro Cat
  • 103
  • 8
  • Does this answer your question? [How to edit (customize) Color Themes in VS2017 Preview](https://stackoverflow.com/questions/40983535/how-to-edit-customize-color-themes-in-vs2017-preview) – Manish Dec 23 '19 at 09:43
  • Are you making a web application or windows application? Add some details about it. If you are making web application then you can use CSS to apply a color to multiple controls. – 24x7Programmer Dec 23 '19 at 09:47
  • If you mean that you want to change a Property value common to multiple Controls, you can use the `ApplicationSettings`; it's accessible from the PropertyGrid. See also the [ApplicationSettingsBase](https://learn.microsoft.com/en-us/dotnet/api/system.configuration.applicationsettingsbase) Class. If this is the case, none of the links (duplicate included) are related to the question. – Jimi Dec 23 '19 at 10:05
  • I will add it is a windows-forms application. Is there a simple way like in android with adding a simple color name? #ffe5a4 to add a color named row_bg – Figaro Cat Dec 23 '19 at 12:27
  • 1
    You can absolutely do it in a similar way. Select a Control in the designer, open the `([+]ApplicationSettings)`, click on `(PropertyBinding) [...]`, select a Property - for example the `BackColor` - and write a name for it. It will be added to the Project's Settings. Do the same to all controls that share the same Setting. Then you can change this Property on one of the Controls and all the others will follow suit when you `Refresh()` the Form. – Jimi Dec 23 '19 at 13:25
  • 1
    You can also change the Setting value. Assuming that the common Property is the `BackColor` and the name assigned to the Setting is `CommonBackColor` you can change the BackColor of all controls with `Properties.Settings.Default.CommonBackColor = Color.FromName("Yellow");`). Use the `ColorTranslator` class to convert from HTML (e.g., `Properties.Settings.Default.CommonBackColor = ColorTranslator.FromHtml("#FFEE00");`) – Jimi Dec 23 '19 at 13:25
  • Jimi you rock :) searched and looked but didn't see anything regarding this. Thanks! – Figaro Cat Dec 23 '19 at 13:39

0 Answers0