System.Drawing.Color

  • Thread starter Thread starter PCH
  • Start date Start date
P

PCH

Let say i want my form to change its background color.

You have to use a system.drawing.color type.. such as "brown". I guess you
cannot pass a hex code.

I want to build a combo box of the different types and their colors (just
like the properties color dropdown in design mode).

Can anyone get me started?

This is for vb.net CF, not c#

Thanks.
 
You can use the Static member FromArgb to specify a colour by value e.g.:-

Color.FromArgb(0xFF0000FF);
returns solid blue. Note the A component is the Alpha channel where FF
represents an Opaque colour. Alpha-blending is not supported on .NETCF.

Peter
 
You actually can specify hex or rgb values by using Color.FromARGB and
passing it either a 32-bit ARGB value or the red, green, and blue
components.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.
 
I did find that option..which will at least allow me to store the value in
xml...

I need to build an actual combobox with its dropdown of available colors
(color) and name..

Is that possible?
 
Hi PCH,

I posted to this yesterday but it apparently did not make it through. You
actually can set a hex color via System.Drawing.Color.FromARGB() which can
take either a 32 bit ARGB color value or 3 byte components representing red,
green, and blue. I hope this helps.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Ah nice! so i can throw in FFFFFF and get the right type?

Now how Can i create a drowndown with the color type name and the color
itself next to it?

Thanks.
 
Hi PCH,

Try searching help in VS for "Creating a Color Picker" (check "Search in
titles only" to optimize it). In the "Smart Device Projects" section you
should get some sample code for creating a color picker control. It is
probably not exactly what you want but should provide a good basis.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.
 
hi,
You can use reflection to iterate through static properties on Color type,
which will allow you get properties such as Color.Red. Sample code (C#)

Type type = typeof(System.Drawing.Color);
PropertyInfo[] properties = type.GetProperties();
foreach(PropertyInfo p in properties)
{
MessageBox.Show("Name " + p.Name);
if ( p.PropertyType==type )
{
Color color = (Color) p.GetValue(null, null);

}
}
 
thx ill check it out

Geoff Schwab said:
Hi PCH,

Try searching help in VS for "Creating a Color Picker" (check "Search in
titles only" to optimize it). In the "Smart Device Projects" section you
should get some sample code for creating a color picker control. It is
probably not exactly what you want but should provide a good basis.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top