views:

8

answers:

0

Hello,

I recently asked this question on here and got the answer. However I'm now trying to apply the same logic on a DataGridView which is bound to a BindingList< T > of Curriculum objects. The Curriculum class has a property of type Year. I'm trying to use a ComboBoxColumn to update the reference the curriculum object has of years.

The comboboxcolumn is bound to a BindingList< T > of years, it errors if I set either the display member or the value member so I left them null. Doing this the datagridview successfully loads and displays the data correctly (I overrode the ToString method on the year class). However, if I choose another year object from the combobox, as soon as it end edits it throws and exception saying it can't convert string to type year.

It looks like I need a TypeConverter to do it, but the problem is the combobox is displaying a descriptive value, which I can't guarantee will be unique to that year object - so I have no way of getting a year object from a given string.

Has anyone got any experience in situations like these, it must be a pretty common thing to want to do but google has failed me on this occasion.

Marlon