[唐胡璐] - DataGridView单元格设置日期格式
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["StartTime"].Index || e.ColumnIndex == dataGridView1.Columns["EndTime"].Index) { if (dpString.dTrim(e.Value) != "") { e.Value = Convert.ToDateTime(e.Value).ToString("MM/dd/yyyy - HH:mm:ss"); } } }