I know how to change the format on a column but is it possible to change the format on a cell by cell basis?
My data is bound to a dataset. This dataset makes the quantity datatype System.Decimal. I then do a test on each row to see what type it is
(string)e.Row.Cells["Dsp_stype"].Value
If the value is a "P" then I want my quantity to display 0.000 or its actual value but when the row type is a "C" I want to display blank. I tried using format "#.###" and I did get the desired results for a "C" row type but type "P" gets butchered. Which I would expect considering the format is for the entire column not just the cell I am trying to manipulate.
I have tried to set the cells Active, Selected and Cell appearances ForeColor to be the same as the BackColor but once the row is selected my overrides are ignored. According to INF support this is by default.
I have added a couple of images to show what my desired results are.
Before a comment row is selected. This is how I want it to look whether the row is selected or not.
After a comment row has been selected.
What I would do is hide the column and add an unbound column to the grid. You can do this in the InitializeLayout event. Then you can use InitializeRow to example the value in the real (hidden) column and populate the cell in the unbound (visible) column with whatever you like.
If the field is updatable, you can reverse this process in the BeforeRowUpdate event.
I will give it a try. I assume that my unbound columns data type would be a string allowing me to move whatever into the cell. If that is the case and the user Exports the grid to Excel I would lose my data type decimal that is currently be used in the hidden column. The user would then have to convert the string to a number to get the calculations to work. Is this an accurate assumption?
You are correct, but you could get around that. You could handle the CellExported event of the UltraGridExcelExporter and when a cell in the unbound column is visible, you could replace the string value that is already written to the cell with the actual value from the real, hidden cell. So the Excel sheet would then contain the real (unformatted) values. And then you could apply a format to the Excel cell (assuming that Excel supports a format you can use) to make it look like the grid cell.
Sounds good I will give it a try. Thanks.