Binding to an enumerated column RRS feed

  • Question

  • I’m on a Windows application using SQLExpress with EF.5  CodeFirst  in VB

    I create an enumerated property. So far everything went well.

    Now I’m trying to create a simple binding over that column to a dropdown list.

    From the binding source to the control, everything is fine but binding source is not updated when I change dropdown list selection.

    Tried a few advices found over the blog but nothing worked

    Tired to bind “text” or “selectedindex” property result is the same, I think binding source is expecting an enum element not a number or a text, but don’t know how to do this

    Can somebody help me ?

    Public Enum EnumNumbers As Short
        zero= 0
        one= 1
        two= 2
    End Enum
    ' ------- in the data class 
    Public Property EnumNbr As EnumNumbers = EnumNumbers.zero 
    ' ------- in the form
    MyCombobox.DataSource = system.Enum.GetNames(GetType(EnumNumbers ))
    MyCombobox.DataBindings.Add("text", MyDatasource, "EnumNbr")
    ' or
    MyCombobox.DataBindings.Add("selectedIndex", MyDatasource, "EnumNbr")


    Sunday, September 1, 2013 11:17 AM


All replies