Is it possible to change the cell.value in a WinFormCore DataGridViewCell

49 Views Asked by At

EDIT:

As György Kőszeg commented, the way to fi my problem ws to override the ToString() value on my Station class, now its returning the desired value

I am populating a DataGridView with a list.

My List contains strings, datetime and classes.

the problem is the Column with the class. it is just showing as the object name. so cell content is: OperatingLog.Model.Station. (datatable picture) Data table showing my the Test column showing entire object

What i would want instead is to show a value from the object. lets say OperatingLog.Model.Station.ExternalId. However when i try to change the cell value (picture of code)

Code snippet

i get this error saying that i cant convert the object to string. error

i just want to add a "label" or something, not change the object.

Only help i found on internet is to make a model with all the fields in strings instead of classes. Model example

however i do not like this approach since the classes can have a lot of properties where i need the data but dont want to show it all.

0

There are 0 best solutions below