If you ever wanted to know how to get all the colour fields in the structure COlor, you can use the following bit of code:
Type t = typeof(Color);
System.Reflection.PropertyInfo[] colours = t.GetProperties();
foreach (System.Reflection.MemberInfo c in colours)
{
// How you would use c, cboxBackColour is a combo box
cboxBackColour.Items.Add(c.Name.ToString());
}
Basically, System.Type class uses the typeof method that can then be adopted to get all the properies within that class using reflection.
Friday, 12 June 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment