I’m struggling getting a certain column within my DataGridView to display things right. It had been working and I must have broken something subtly, now all I get is an empty string. Does anyone know why this might be?
// this inherits from DataGridView
this.Rows.Add(new object[]
{
"test",
new CustomType("A", "1")
});
CustomType()
{
...
public override String ToString()
{
return this.String1 + ":" + this.String2;
}
}
The result of such a thing is my Row.Cells[1].Value is “A : 1”. However the FormattedValue is always blank…
Ok, I managed to find the cause of this… Unfortunately it was an annoying designer change whereby it lost the information that the column was bound to when I removed a different control from there.
This means that the databinding was not set, and hence it didn’t know how to display the value.