Skip to content

Commit 5f93a37

Browse files
Fix DateTime display to show seconds in table data
1 parent e5aba96 commit 5f93a37

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

Source/Editor/Controls/DataGridViewEx.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,24 @@ public override Font Font
3131

3232
protected override void OnCellFormatting(DataGridViewCellFormattingEventArgs e)
3333
{
34-
e.CellStyle.Font = e.Value == DBNull.Value ? italicFont : normalFont;
35-
e.CellStyle.ForeColor = e.Value == DBNull.Value ? SystemColors.GrayText : SystemColors.WindowText;
34+
if (e.Value == DBNull.Value)
35+
{
36+
e.CellStyle.Font = italicFont;
37+
e.CellStyle.ForeColor = SystemColors.GrayText;
38+
}
39+
else
40+
{
41+
e.CellStyle.Font = normalFont;
42+
e.CellStyle.ForeColor = SystemColors.WindowText;
43+
44+
// Format DateTime values to include seconds
45+
if (e.Value is DateTime dateTimeValue)
46+
{
47+
e.Value = dateTimeValue.ToString("yyyy-MM-dd HH:mm:ss");
48+
e.FormattingApplied = true;
49+
}
50+
}
51+
3652
base.OnCellFormatting(e);
3753
}
3854

0 commit comments

Comments
 (0)