c# - Datagridview combobox business object updating reference -
i asked question on here , got answer. i'm trying apply same logic on datagridview bound bindinglist< t > of curriculum objects. curriculum class has property of type year. i'm trying use comboboxcolumn update reference curriculum object has of years.
the comboboxcolumn bound bindinglist< t > of years, errors if set either display member or value member left them null. doing datagridview loads , displays data correctly (i overrode tostring method on year class). however, if choose year object combobox, end edits throws , exception saying can't convert string type year.
it looks need typeconverter it, problem combobox displaying descriptive value, can't guarantee unique year object - have no way of getting year object given string.
has got experience in situations these, must pretty common thing want google has failed me on occasion.
marlon
same problem here. seems object binding in combobox column doesn't work , have specify valuemember.
for particular project working on, came conculsion not worth implementing custom type descriptor, instead, using horrible hack:
in entity binding to, have following:
class testentity { public testentity bindinghack_valuemember { { return this; } } public string bindinghack_displaymember { { return this.tostring(); } } }
and databinding column looks this:
column.datapropertyname = "foo"; column.displaymember = "bindinghack_displaymember"; column.valuemember = "bindinghack_valuemember";
a little ugly, perhaps, works ...
Comments
Post a Comment