UCM Posted April 14, 2003 Posted April 14, 2003 I've been trying to modify that code to allow me to get the names of all the known colors... so far, no luck -_- any ideas? Dim ff2 As String Dim ifc1 As System.Drawing.KnownColor For Each ff2 In ifc1 Dim zz = ComboBox3.Items.Add(ff2) If ff.Name = "Black" Then ComboBox3.SelectedIndex = zz Next Quote UCM >-)
*Experts* Volte Posted April 14, 2003 *Experts* Posted April 14, 2003 I haven't tested this yet, but you might be able to get all the fields in the KnownColor type to get them.Dim col As Reflection.FieldInfo For Each col In GetType(KnownColor).GetFields ListBox1.Items.Add(col.Name) Next Quote
UCM Posted April 14, 2003 Author Posted April 14, 2003 niiice, VolteFace... it got the name of every property including the color names :) hmmm... how do we get it to refrain from pulling in the non-color properties... So far this is the closest I've come: Dim col As Reflection.FieldInfo For Each col In GetType(KnownColor).GetFields If col.MemberType.GetTypeCode = TypeCode.Int32 Then ComboBox3.Items.Add(col.Name) End If Next Quote UCM >-)
*Experts* Volte Posted April 14, 2003 *Experts* Posted April 14, 2003 What non-color fields do you mean? The only non-color field I can see is 'value__' and that is easily removed. However, I believe the correct way to filter them would be this:If col.FieldType Is GetType(Drawing.KnownColor) Then Quote
*Experts* Volte Posted April 14, 2003 *Experts* Posted April 14, 2003 Here's another, possibly better way:Dim cols() As String cols = [Enum].GetNames(GetType(KnownColor)) ListBox1.Items.AddRange(cols) Quote
UCM Posted April 15, 2003 Author Posted April 15, 2003 Sweet!! yup, your better way does work best... GetType... Think I'll do some additional research on that ;) thanx again, VolteFace Quote UCM >-)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.