Answered by:
Binding to an enumerated column

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")
BB
Sunday, September 1, 2013 11:17 AM
Answers
-
Convert it to VB it can't be that hard.
- Marked as answer by Fred Bao Monday, September 9, 2013 2:59 AM
Sunday, September 1, 2013 4:09 PM -
Then I suggest that you post to a Windows UI form forum like MSDN VB.NET General and ask questions about the bindings.
- Marked as answer by Fred Bao Monday, September 9, 2013 2:59 AM
Monday, September 2, 2013 10:53 AM
All replies
-
Convert it to VB it can't be that hard.
- Marked as answer by Fred Bao Monday, September 9, 2013 2:59 AM
Sunday, September 1, 2013 4:09 PM -
Thank you for your reply, but this thread relates only to the part that is already working for me. (Loading and controlling a combo box from an enum) my problem is with the “return path” of the binding. (What happens to the bindingSource when my combo’s selected item changes)
Regards.
BB
Monday, September 2, 2013 8:07 AM -
Then I suggest that you post to a Windows UI form forum like MSDN VB.NET General and ask questions about the bindings.
- Marked as answer by Fred Bao Monday, September 9, 2013 2:59 AM
Monday, September 2, 2013 10:53 AM