c# - DataGridView DataBinding get selected object from Combobox -
i have datagridview
, 1 of column combobox (datagridviewcomboboxcolumn)
binded property of objects. datagridview format cell calls tostring()
of objects. combo list strings , try select combobox
error because program trying set string object. how solve it? select combobox
object value not string.
i have collection of objects (myobject
) contains property
public reason kind { get; set; }
reason has method tostring() datagridview calls automaticly. while select value combobox not reason
object, string
you need use displaymemberpath property on datagridviewcomboboxcolumn
<datagridviewcomboboxcolumn displaymemberpath="propertyname" />
Comments
Post a Comment