Home Forums WinForms controls Xceed Grid for WinForms how to format system.timespan to hh:mm Reply To: how to format system.timespan to hh:mm

User (Old forums)
Post count: 23064

<pre>class TimeSpanCellViewer : CellViewerManager
protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement)
if (value == null || value is DBNull || value == formatInfo.NullValue)
return formatInfo.NullText;

if (value is TimeSpan)
TimeSpan lValue = (TimeSpan)value;
return string.Format(“{0}:{1}”, lValue.Hours, lValue.Minutes);

return value.ToString();

Imported from legacy forums. Posted by Tommy (had 663 views)