I have an UltraGrid where the values are integers (ids).
I have a ValueList which maps the ids to strings.
Some cells need to be empty. In those cases, the values are -1. I tried to map -1 to string.Empty, but I figured that ValueListItems.Add ignores string.Empty as an argument.
I tried another trick, by setting the foreground = background in those cells. However, when I hover with the mouse over those cells, -1 is displayed, as you can see in the screenshot. The cell above the highlighted row also has the value -1, but it is not displayed, which is the result I desire.
cell.Appearance.ForeColor = cell.Appearance.BackColor;cell.SelectedAppearance = cell.Appearance;cell.ActiveAppearance = cell.Appearance;cell.ButtonAppearance = cell.Appearance;
I tried hiding the cell when the value is -1, but then the background becomes gray. We want the background remain white.
Is there a way to display a white background and hide the value -1, in all cases?
Thank you very much for the quick reply. Using single space solved my problem.
There are a couple of approaches you could take. You can't use an empty string in your ValueList, because the ValueList interprets that as an empty or null value and so it is just ignored. But you could use a single space character.
Another option would be to use a DataValue of DBNull.Value (instead of -1). This won't work if the grid's data source doesn't allow nulls.
Another option would be to set the ForeColor of the cell to Color.Transparent, instead of using the BackColor.
And yet another option would be to use a CreationFilter or a DrawFilter.