Pick a Color, Any Color (or Several Colors, For That Matter)
If you want to use colors in your app other than the standard ones for which there are constants defined, you can create your own using Color.FromArgb()
, which returns a color comprised of the combination of values you pass (the first arg is the amount of red in your custom color, the second is the amount of green, and the final is the amount of blue. e.g., passing 14, 56, and 46, respectively, gives you a forest green color.
If you want to mimic an existing color or color scheme, you first need an image that contains that or those colors. If you don't have one, you can take a screenshot from a web page that does, and save that as an image file.
Next, load the image file into http://html-color-codes.info/colors-from-image/.
Then, show the loaded image in that page, and click on the area of the image that contains the color of interest
Next, copy the hex value provided, and then convert it to its RGB value by pasting it into the "Hex" box at http://hex.colorrrs.com/.
Now, copy the RGB value from there, and create a constant for the color, such as:
private static readonly Color GREEN_BAY_PACKERS_GREEN = Color.FromArgb(14,56,46);
Finally, call it from your C# app like so:
grandTotalsItemsRange.Interior.Color = GREEN_BAY_PACKERS_GREEN;
Of course, the usefulness of this is not limited to colorizing the background of Excel ranges; you can assign the color to any object's Color
property, such as for text, etc. -- any place you assign to a Color
property.
Like Sunlight Streaming Through Evergreens
As a bonus, here's another great color
:
private static readonly Color GREEN_BAY_PACKERS_GOLD = Color.FromArgb(240,184,1);