We have several WinGrids that we use as read only search results. We use 1/1/1900 as a placeholder for a date that has no real value yet. Previously we had been using string typed columns for dates and then could use a ValueList to 'hide' the 1/1/1900 dates in the grid like this:
vl.ValueListItems.Add("1/1/1900", " ")vl.ValueListItems.Add("1/1/1900 12:00:00 AM", " ")vl.ValueListItems.Add("01/01/1900", " ")vl.ValueListItems.Add("01/01/1900 12:00:00 AM", " ")
Now we are using DateTime typed columns for dates and when the WinGrid column is set to a date style (so it will sort as a date, not as text) the above trick no longer works. Basically, if the style is default, the ValueList will hide the value in the cell but the sort is text; if the style is any of the Date ColumnStyles then the sort works as expected but the 1/1/1900 values display in the grid.
I've considered something in InitializeRow or maybe even a custom IComparer but both feel like I'm covering up the symptoms rather than fixing the problem. Any ideas?
Hi,
There are a number of ways you could achieve what you want. If the cell is read-only, then the easiest thing to do would be to use InitializeRow and simply set the Hidden property on the cell.
If you don't like the way that looks (with a big empty space where the cell would have been), then the next best option would be to use a CreationFilter to change the text in the UIElements without affecting the data. If you want to go that route, let me know, and I will whip up a small sample CreationFilter for you. It should be pretty simple.
Hiding the cell will not work as we are styling the grids and a big empty space will not look right.
I've done some CreationFilter stuff before, but not connecting how I would use it here. If you could give me a quick example to get me started that would be great.