I’ve a combobox that is binded to a FK entity (the object, not the ID-field). The combobox is filled with a Linq-query-ToList(). DisplayMember is set, ValueMember is empty. Property SelectedItem is used for binding. This all works fine, except if the FK is empty/null, the first item in the combobox is selected, while if I check out the Linq-object I can see that the FK is null. In this case I want the selecteditem of the combobox to be null as well. Am I missing something?
Share
It seems that this works:
Taken from http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/a530f011-54d9-44d1-a585-145ea28ff370/
“I’ve tested this solution but this will not help if you bind to custom object and set property of object (which is bound to combobox) to null value. Note: I’m binding SelectedItem property
my solution to is derive combobox and force SelectedItem to act correctly”