i have a datagrid with the following cell formatting
datagrid.rows[0].cells[0].Value =1;
datagrid.rows[0].cells[0].Style.Format ="#k";
this works fine and the output will be 1k, however when the user edit the cell value example to 2 then cell formatting will not take effect?
question is how can i retain the cell formatting after user edit?
thanks
I guess you are not working with an underlying datasource. You are inserting
DataGridViewRowsmanually into theDataGridView.If you were using a datasource, if the column datatype was numeric, the styling will work in both edit and readonly modes.
In your case, you need to handle the
CellFormattingevent of theDataGridViewand set the format of your cell there: