I have a databound datagridview. In it I have a column that has NULL values and 1-12. How can I at runtime make the datagridview turn the 1 into January and display it in the cell? And the NULL into another pre-defined string?
I tried looking at the cell format, changed it to custom, then put in "MMM" but it did not work and displayed "MMM" in the actual cell.
Please help.
EDIT: Its winforms c#4.0, the field is bound to Int field from an entity in EF. And no need for culture sensitive, english is fine.
EDIT: I tried {0:MMM} it didnt work, just displayed {X:MMM} in cell where X is int.
Some screenshots:
If WinForms try this:
Use Column.DefaultCellStyle.Format property or set it in designer.
This post should clarify any doubt:
Customize format of DateTime string in WPF and WinForm data binding
PROBLEM: string formatting masks will only work with DateTime values. You have int and in this case I think you'll have to write a converter function...
Check this:
DataGridView.CellFormatting Event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With