Jump to content

Need help wizards

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
williamevanl

williamevanl

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
I did the friendly name thing with an enumeration with the following code:

[StringValue("Not Found (90% - 100% NF)")]
     NotFound = 1,
    [StringValue("Cluster near NTC")]
    ClusterNTC = 2,
    [StringValue(" Fam/Het Collapse")]
    FHCollapse = 3,
    [StringValue("Red/Het Collapse")]
    RHCollapse = 4,
    [StringValue("Het/Fam Collapse")]
    HFCollapse = 5,
    [StringValue("Het/Red Collapse")]
    HRCollapse = 6,
    [StringValue("Fam Spread")]
    FSpread = 7,
    [StringValue("Red Spread")]
    RSpread = 8,
    [StringValue("Het Spread")]
    HSpread = 9,
    [StringValue("General Spreading")]
    GSpread = 10,
    [StringValue("Weak Red Arm")]
    WRArm = 11,
    [StringValue("Weak Fam Arm")]
    WFArm = 12,
    [StringValue("Many Hets")]
    ManyHets = 13,
    [StringValue("Low signal")]
    LowSignal = 14,


and

 public class StringEnum
    {
        public static string GetStringValue( Enum value)             //Function for Friendly enumerations    
        {
            string output = null;
            Type type = value.GetType();
            FieldInfo fi = type.GetField(value.ToString());
            StringValue[] attrs =
            fi.GetCustomAttributes(typeof(StringValue), false) as StringValue[];
            if (attrs.Length > 0)
            {
                output = attrs[0].Value;
            }
            return output;
        }
       
    }


Now I want to bind that information to a combobox with the easily read values. I can access the shortened values with:

 comboBox1.DataSource = Enum.GetValues(typeof(Marker_Issues));


But how do I access the long names for something like:

 comboBox1.DataSource =  "What goes here??? "
I had guessed something like:

 //comboBox1.DataSource = StringEnum.GetStringValue(Marker_Issues);
but this doesnt work.

I keep running into this in my program, I need to access these values but I don't know what to use.

Edited by williamevanl, 09 April 2010 - 09:48 AM.


#2
williamevanl

williamevanl

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
Found Answer, thanks though.