Compact Framework Colors

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

In VB.NET you can display colors with a routine such as below. Is there a
way to do this in the compact framework?

Thanks!



Private Sub ShowColors()

Dim color As System.Drawing.Color

For Each color In _

System.ComponentModel.TypeDescriptor.GetConverter(GetType(Color)).GetStandar
dValues

Me.ListBox1.Items.Add(color.ToKnownColor)

Next

End Sub
 
Actually as a follow up to my own question -- if you know the color type as
a string, such as "Lime", how can you assign that to a brush (for example)
in the compact framework?

Thank you!
 
Well, I sort of solved the problem using the RGB values instead; it's not as
user friendly but gets the job done!
 
If you know the color name you can use the following code:

Color clr = (Color)typeof(Color).GetField("Lime",
BindingFlags.Static|BindingFlags.Public).GetValue(null);

or in VB.NET

Dim clr as Color
clr = CType(clr.GetType().GetField("Lime", BindingFlags.Static +
BindingFlags.Public).GetValue(Nothing), Color)

This uses System.Reflection.

Similarly you can enumerate standard colors. There was a sample on
OpenNETCF.org. Unfortuantely it is down right now - thanks to our friends in
Dallas running into a routing loop, so I cannot provide a link. Just search
there for Color
 
Back
Top