Bind Combobox with Enum Description

Viewed 14484

I have seen through Stackoverflow that there is an easy way to populate a combobox with an Enumeration:

cbTipos.DataSource = Enum.GetValues(typeof(TiposTrabajo));

In my case I have defined some Description for my enumerations:

 public enum TiposTrabajo
    {                  
        [Description("Programacion Otros")] 
        ProgramacionOtros = 1,           
        Especificaciones = 2,
        [Description("Pruebas Taller")]
        PruebasTaller = 3,
        [Description("Puesta En Marcha")]
        PuestaEnMarcha = 4,
        [Description("Programación Control")]
        ProgramacionControl = 5}

This is working pretty well, but it shows the value, not the description My problem is that I want to show in the combobox the description of the enumeration when it have a description or the value in the case it doesn't have value. If it's necessary I can add a description for the values that doesn't have description. Thx in advance.

2 Answers
Related