how to change transparency of a color in c#

c#

Solution

There is a method that does exactly what you need Color.FromArgb(int alpha, Color baseColor).

Valid `alpha` values are 0 through 255. Where 255 is the most opaque color and 0 a totally transparent color.

Use example

Color newColor = Color.FromArgb(newAlpha, mycolor);

Problem

I am using SSRS reportviewer to generate a report using objects. In my program, I am asking the user to input a string of commonly known colors such as `"Red"`, "`Blue"`, etc. I would like to then generate three shades of this color and use this color to fill an area chart in my report. I do so my changing the opacity (alpha) of the color. This is my code that converts the string to color: ``` newitem.ChartColor = "red"; Color mycolor = Color.FromName(newitem.ChartColor); ``` However, now I would like to generate two more colors with same shade as red but different alpha (opacity) so that they appear lighter, something like `#56FF0000` I tried passing a value to the `A` property of Color however, it is read-only. Any help appreciated.

Original source