none
Collection Editor for enum -C# RRS feed

  • Question

  • I have a userControl to store filters of Destino. My code is below:

    //In UserControl 
    
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public List<Destino> DestinosFiltro { get; set; }
    
    
    //enum
    public enum Destino
    {
       [Description("Receita")]
       Receita = 0,
       [Description("Despesa")]
       Despesa = 1,
       [Description("Ativo")]
       Ativo = 2,
       [Description("Passivo")]
       Passivo = 3,
       [Description("Transitório")]
       Transitório = 4
    }  
    

    Then the property DestinosFiltro appears in the Properties Page in Design mode. And when I am trying to edit this property in design time, a collection editor appears and work fine. But when I close the collection editor, the value entered is cleared. The value of the property DestinosFiltro is losted. Where is my mistake?  

    Thank for all.

    Wednesday, April 22, 2015 2:08 PM

Answers

All replies

  • Try adding this line to the constructor:

        DestinosFiltro = new List<Destino>();

    Wednesday, April 22, 2015 5:02 PM
  •  Hi Thiago,

    I have tested your code,  Just follow your scenario, It will shows the error message as below.

    So you should do as Viorel suggested.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 23, 2015 6:22 AM
  • Thanks a lot. It's works fine.
    Thursday, April 23, 2015 2:40 PM