DataGrid and DateTime formatting

May 18, 2009 at 4:00 PM

I have a SourceGrid.DataGrid which is bound to a System.Data.DataTable, the DataTable contains a few columns including a DateTime.   I need to be able to sort on the DateTime column, And I also need the DateTime to be in the format "hour:minute:second:am/pm".  I've tried two approaches so far, and neither meet both requirements.

 

Approach 1: Declare the column as type DateTime.  The sorting works great, but it displays in the format "day/month/year hour:minute am/pm".  The seconds field is required for the application I'm working on, so this is out.

Approach 2: I wrote a simple class called DateTimeWrapper that holds a DateTime.  The ToString method prints out the DateTime in the correct format, and I setup CompareTo() to just call DateTime's CompareTo().  However this doesn't sort properly.

 

I'm pretty new to SourceGrid, and I'm all out of ideas.

Coordinator
May 19, 2009 at 4:17 PM

There is an example witch should show how to display  a cell with custom formmating, try looking there. Should be somthing useful