My DataGridView
date column is displaying a "dd/MM/yyyy 12:00:00 AM" format. I have looked and find this similar question, and used this method. But still the DataGridView
is displaying all rows with 12:00:00 AM.
When I try to query the database
But when I run the application and populate my DataGridView
I tried adding this to my code, it still shows the 12:00:00 AM
dataGridCust.Columns["Date"].DefaultCellStyle.Format = "dd/MM/yyyy"; //or
dataGridCust.Columns["Date"].DefaultCellStyle.Format = "dd-MM-yyyy"; //or
dataGridCust.Columns["Date"].DefaultCellStyle.Format = "d"; //or all of them
or
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridCust.DataSource = dt;
for (int i = 0; i < dataGridCust.Rows.Count; i++)
{
dataGridCust.Rows[i].Cells[11].Value.ToString("d");
}
If I change the for loop statement to
dataGridCust.Rows[i].Cells[11].Value.ToShortDateString();
It throws an error.
CS1061 C# 'object' does not contain a definition for 'ToShortDateString' and no extension method 'ToShortDateString' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
But when I run it on a lower OS (W7)
Why in W10, where I developed the app and where the sql server is, it displays 12:00:00 AM?
Other similar problems I saw and tried the solutions but no luck.
EDIT:
Windows 7 Region settings
Windows 10 Region settings