Hi there,
I have a bound DateTime column in my ultragrid where the date is editable. Now I want to show some special dates (e.g. 1/1/1900) with a readonly representation (e.g. simple text like "n/a" or maybe an icon) but i can't achieve this because when I set the value of the cell it has to be a DateTime.
Can anyone help me out?
Achim
This KB article demonstrates how to use the IEditorDataFIlter interface to/from convert strings and booleans. You can use the same approach to solve the problem you describe here (the text aspect of it anyway). This interface allows you to intercept the passing of values between the editor and the display, so you would have the opportunity to convert (for example) the value "n/a" to a DateTime and vice versa.
Note that you can't use this approach to display an icon instead of the value, but the UltraGridCell object exposes an Appearance property which in turn exposes an Image property, and you can assign a value to this property to display an image within the cell next to the value. You could also assign an EmbeddableImageRenderer to the cell's Editor property, and then set its value to an image, which would display ony the image in that cell while allowing the other cells in that column to display a DateTime.
Brian,
thanks for your reply. Your solutions work partly for me (and my colleagues ;) ). Your suggestion using an embeddable image renderer is very interesting. But I did not manage getting it to work. When I assign an Image to the Value of the cell (it is unbound in this case) I get an error that the value has to implement IComparable. So how is the renderer thought to be used?
Thanks for your help.
PS: maybe I have to ask my question in another way: I'm looking for a way to render cell contents in a customized way, regardless if the column is bound or unbound.