views:

156

answers:

2

After a quick subclassing of Windows.Forms.Label and then noticing that the default Label is able to use semi-transparent background colors just fine, I wonder whether there is actually a way to pick them in Visual Studio. The Color picker in the property Grid allows me to pick custom, Web and System colors but doesn't allow me to define an alpha value.

Right now I'm doing this through code:

this.lblTime.BackColor = Color.FromArgb(96, Color.Black);

but it'd be nice if the Designer itself would allow for that in the first place.

Am I overlooking something or is this actually not possible?

A: 

I thought you might be able to do this through the Windows Color Picker Dialog (as VisualStudio seems to be using part of this as its color picker control) by opening it, selecting a custom color there, making sure it is one of the 16 custom colors in the palet, and then seeing this color as being available in VisualStudio in the same custom color palet location. However, on opening the dialog through Display Properties, Advanced Appearance, editing a custom color it turns out that the Windows Color Picker Dialog itself doesn't even support colors with alpha values other than 255. So it seems this is not possible at all in default VisualStudio designers.

Maybe if you write a custom edit control for System.Color? Is there a way then to let VisualStudio use your own color editor instead of the default one?

peSHIr
+1  A: 

If you know the RGB value you want, then you can just enter, by hand, into the color property field:

128, 255, 255, 0

to get a 50% transparent yellow, or

64, 0, 0, 255

to get a 25% transparent blue...

danbystrom
Whee, that's nice. Thanks :-)
Joey