Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
Howto display aDateTime column in different styles?
posted

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

Parents
No Data
Reply
  • 69832
    Suggested Answer
    Offline posted

    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.

Children