Color ComboBox Populating

N

NvrBst

I have a dropdown list, then right now I simply call

BGColorComboBox.DataSource =
Enum.GetValues(typeof(KnownColor));
BGColorComboBox.SelectedItem = KnownColor.Black;

Which works great except it has some values I don't want... Everything
in the "SystemColor" enumeration actually (IE "ActiveBorder"
"ControlDark").

Is there a easy/fast way to hide all the "SystemColor" enum values from
the ComboBox after it has all the "KnownColor"'s in it? Or easy way to
just make a new enum that is the "KnownColor" enum minus the
"SystemColor" enum?


Or... All the colors I want are public static members of the
"System.Drawing.Color" stuct... (IE "System.Drawing.Color.AquaBlue").
Can I populate the combo box with only the static members of the
"System.Drawing.Color" stuct easily/fast?

Or they have "SystemColor" "ConsoleColor" "KnownColor" enums... is
there a "WebColor" or "ActualColor" enum already created that I just
coudln't find?

Thanks NB
 
N

NvrBst

Found a way :)

List<object> ALColor = new List<object>();
foreach(object clr in Enum.GetValues(typeof(KnownColor)))
if(!Color.FromKnownColor((KnownColor)clr).IsSystemColor)
ALColor.Add(clr);
BGColorComboBox.DataSource = ALColor;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top