// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace E { public partial class MainForm : Form { public MainForm() { InitializeComponent(); List lst = new List(); lst.Add(new Data { ID = 1, Delta = new TimeSpan(100000) }); lst.Add(new Data { ID = 2, Delta = new TimeSpan(110000) }); lst.Add(new Data { ID = 3, Delta = new TimeSpan(120000) }); dataGridView1.CellFormatting += FixTimeSpan; dataGridView1.DataSource = lst; } private static void FixTimeSpan(object sender, DataGridViewCellFormattingEventArgs e) { if(e.Value.GetType() == typeof(TimeSpan)) { e.Value = ((TimeSpan)e.Value).TotalSeconds.ToString("0.00##"); e.FormattingApplied = true; } } } public class Data { public int ID { get; set; } public TimeSpan Delta { get; set; } } }