I have a DataGridView that I’m binding to a DataTable.
The DataTable is a all numeric values.
There is a requirement that every n rows in the DataGridView has text in it, rather than the numeric values (to visually separate sections for the user).
I am happy to put this text data in the DataTable or in the DataGridView after binding, but I can’t see a way to put this text data in either as the column formats for both require numeric data – I get a ‘can’t put a string in a decimal’ error for both.
Any ideas how I change the format of a particular row or cell in either the DataTable or DataGridView?
You can provide a handler for the DataGridView’s
CellFormattingevent, such as:For assistance on creating your own styles, refer to the
DataGridView.CellFormatting Eventtopic in the online help.