I have a sqlite DB with a column Integer were a duration in milliseconds is stored. I use xceed grid .net to display the content of the DB and i want to display the duration as the following:
Dim ts = TimeSpan.FromMilliseconds(Row.Cells("Duration").Value)
Dim temp As String = ""
temp = String.Format("{0:D2}d.{1:D2}h:{2:D2}m:{3:D2}s:{4:D3}ms", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds)
Example:
?Row.Cells("Duration").Value
133642 {Long}
Long: 133642
?temp
"00d.00h:02m:13s:642ms"
So how to directly display this in the grid column? Because the Grid column type is an integer so an error is thrown if i just assign the new value. However if i define the column as string - of course i can assign the formated value but if i do this the ability to sort by clicking on the column is lost.
I would like to do something like this (assuming the DB column and xceed column is still integer:
Dim ts = TimeSpan.FromMilliseconds(Row.Cells("Duration").Value)
Row.Cells("Duration").FormatSpecifier = String.Format("{0:D2}d.{1:D2}h:{2:D2}m:{3:D2}s:{4:D3}ms", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds)
But if i do this the column looks very weird:
?Row.Cells("Duration").GetDisplayText
"133642d,00h:02m:13s:642ms"
Any ideas how to this correctly?
Aucun commentaire:
Enregistrer un commentaire