Codelog

foreach(Snippet aSnippet in CodeLog){ aSnippet.GetSolution(); }

DoUNo: DisplayMember getting reset on DataSource=null

without comments

I have a ComboBox whose items are set using the DataSource property. The DataSource is a collection of a custom object (that has a string property ‘Value’ and int property ‘Id’). In the initialise controls, I set the DisplayMember as Value and ValueMember as Id. Now I tried to clear the DataSource by calling,

myComboBox.DataSource = null;

When I did that, my ComboBox’s DisplayMember is reset to “” automatically. This was not I expected, but this is how it behaves as a .Net control. Thought it would be helful sharing it.

More @ http://stackoverflow.com/questions/641809/displaymember-getting-reset-on-datasourcenull

Written by sudarsanyes

March 13th, 2009 at 1:54 pm

Leave a Reply