Hi all,
I'm using a custom type for cells values of the grid (say CustomCell). When the grid is rendered it calls the CustomCell.ToString() method. So, the only thing I need is to override the ToString method of the CustomCell class. The CustomCell objects represent only numeric values.
Now we have a requirement to show some cells of the same column in a currency format ("$nnn.nn") and some cells still in a "regular" format. That would be logically to set for some cells the Currency style. However, this will not work, because I'm not using numeric values as cells values.
Is there a simple way some cells of the same column can be in the currency format while other ones in "regular"? I would like to change the CustomCell only by implementing IFormattable.
Thanks,
Vitaly
There's really no simple way to format different cells in the same column with different formats.
One way you could do this is with a DrawFilter - this would allow you to draw the text in the cell yourself. I assume the cell is not updatable by the user.
Another optoion would be to use a DataFilter. The advantage to this approach is that you don't have to get involved in drawing text with GDI+. The disadvantage is that you need to convert the text both ways - formatting it and then unformatting it.
Still another option would be to use a CreationFilter and change the text of the TextUIElement in the cell.
And still another option would be to hide the real bound column in the grid, add an Unbound column, and then use the InitializeRow event to populate the unbound column with the formatted text you want, based on the value of the bound column in the same row. This last approach is probably the easiest.
Has anyone placed a feature request for this functionality? Specifically something like a Format property at the cell level? If not can I request it now?
I have a similar situation with a variables UltraGrid. Depending on the variable type, the value can be a date, amount, number etc. I started down the DataFilter approach but none of these solutions are ideal.
This seems like a rather common, reasonable request. It is great that we can control various aspects at cell level like so many appearence settings. Personally though I am more interested in functionality that helps with working with the data than having UX eye candy.