Reputation: 21
I have a DataGridView
with a DateTime
formatted column.
On load it is showing the system DateTime
format and on click of cell it is showing server DateTime
format. I want to always use server DateTime
format.
If I change the system DateTime
format, the cell value format should not change.
Example: Server DateTime
format is "dd/MM/yyyy hh:mm tt"
whilst system DateTime
format if I change is "dd-MM-yyyy hh:mm tt"
.
Upvotes: 2
Views: 272
Reputation: 35
Place the below code in the Form_Load
event and change the DataGridView
name, Columns[No]
and the date format as required:
me.dataGridView1.Columns[1].DefaultCellStyle.Format = "dd/MM/yyyy hh:mm:ss tt"
Upvotes: 2