i want to loop through each avaiable color in Color struct.
Is that possible?
5
Contributors
10
Replies
3 Years
Discussion Span
3 Months Ago
Last Updated
13
Views
Question Answered
Related Article:Circular loop
is a C# discussion thread by de Source that has 2 replies, was last updated 7 months ago and has been tagged with the keywords: for, loop, circularcondition.
Depends on what you want Serkan.
This http://www.daniweb.com/code/snippet1022.html loops through what is called the KnowColors.
All the colors would need 256*256*256 iterations I guess.
i dont have knowncolor, i am using on compact framework. i have System.Drawing.Color struct. and i has properties. i want to read those property values maybe using reflection.
no, what i want is something simple, we have colors in System.Drawing.Color. all i want is to create a color picker.
I get angry when something gets hard for no reason as now.
foreach (PropertyInfo p in typeof(Color).GetProperties())
{
Color c = new Color();
if (p.PropertyType == typeof(Color))
{
ListViewItem lvi = new ListViewItem(p.Name);
lvi.ForeColor =(Color) p.GetValue(c,null);
listView1.Items.Add(lvi);
}
}
foreach (PropertyInfo p in typeof(Color).GetProperties())
{
Color c = new Color();
if (p.PropertyType == typeof(Color))
{
ListViewItem lvi = new ListViewItem(p.Name);
lvi.ForeColor =(Color) p.GetValue(c,null);
listView1.Items.Add(lvi);
}
}
Project is attached
Sir can u explain the ur code that how its work especially what is propertyinfo and what is its function.
Serkan, great example. I just noticed what is clearly a typo on your code. You want to iterate through the properties of the Colors (not Color) class. Maybe an edit would help people grasp this better. Thanks for the code. Helped.