I have a DataGridView with a column that holds DateTime values like this:
The problem is in the selected row: it actually has the value "10/07/2015 12:00:00 am" but in the datagridview it is shown only "10/07/2015". The next row has the value of "10/07/2015 12:00:26 am". This problem happens only when the hour of the DateTime values is exactly midnight. When I pass that value to a textBox (to the left) with the following code, DateTime value is shown correctly (DateTime values are in the column with index 2):
text1.Text = dgView.SelectedRows[0].Cells[2].Value.ToString();
How can I make my DataGridView to show the complete DateTime values? I do not want to set the DefaultCellStyle.Format value because I want to show the DateTimes in the format of the OS regional settings (in my case is es-pe).
I'm targeting .Net 3.5 compiled for x86.
You could specify the DefaultCellStyle.Format
, but use a "standard format" which will localize appropriately:
DefaultCellStyle.Format = "g"; // General date, short time pattern
I don't know that that will format midnight "fully", but it's worth a try.
See more on this question at Stackoverflow