Formatting dates in a data grid view to display seconds.

private void DataGridView1_ColumnAdded(object sender, System.Windows.Forms.DataGridViewColumnEventArgs e)
{
 if (object.ReferenceEquals(e.Column.ValueType, System.Type.GetType("System.DateTime"))) {
  e.Column.DefaultCellStyle.Format = "yyyy-MM-dd hh:mm:ss";
 }
}

No comments:

Post a Comment