Hello
How can I make the grid to display nothing when the value is zero?
Thanks a lot
Hi EmoscosoCam,
If you want to display a null value in the cell you may need to assign it a string type. Assuming our column name is "Zero", in the Grid's Initialize_Row adding the following code snippet:
string i = e.Row.Cells["Zero"].Value.ToString(); string zero = "0"; if (string.Compare(i,zero)==0){ e.Row.Cells["Zero"].Value = null;
This will display a null value in the cell.
Thanks.
By the way, is the value is greater that zero, I have a format string the displays it as a percentage.
Hi,
I think setting the value to null is not what you need. You want only to display nothing but leave the value as zero.
I suggest using a value list with on item with zero value and null text. Whe the value is zero, you'll see nothing. For any other value, you'll see the value itself.
You can use a Data Filter class. Also you have control over what you are exporting to excel using the
ultraGridExcelExporter's CellExporting and CellExported events.
Thanks! This is a nice trick, however it has some issues: The value list item has to have a single whitespace " ", because when using a NullString the cell displays the original zero. However, if I export the grid to Excel, that cell is interpreted as text and therefore I cannot straightforwardly use it in formulas.
What about using a DataFilter class?