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
320
Data Format Problem!
posted

I am using with the WinGrid features, and I have a problem on Date Time formatting.

My project requirement is that, I have to show "Time" which is DateTime field on Database. I have implemented that successfully.
However, when I try to sort against this field, it will ignore the Date (Because the grid show the time only)

For example:
DB Store "03/12/2008 14:57"
The Grid Show
1457

Is that possible to override the grid sorting behaviour to adept that? Or is that I do something wrong with it (Since the 1457 which I prepared in DataTable that is the datasource of the grid)

 Tks and Regards
AnDrew

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi Andrew,

    So you want to show only the time, but sort on both the date and the time? That seems like an odd user experience. Will the users understand they times appear out of order? 

    Anyway, the grid's sorting is based on what is visible to the user. You can change the sorting behavior, though, by applying a SortComparer to the grid column. You just create a class that implement IComparer and implement the Compare method. The x and y parameters that get passed into the Compare method will be two UltraGridCell objects and you can decide which is greater.

Children