4,103 questions
Try this:
testGrid.Columns[3].DefaultCellStyle.Format = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a datagridview on a winform's form. I need to set the format of one of the columns in the grid to the currentculture's datetime format.
I was doing (bad, I know)
testGrid.Columns[3].DefaultCellStyle.Format = "MM/dd/yyyy". But that doesn't work on a european system.
DateTimeFormatInfo dtFormat = CultureInfo.CurrentCulture.DateTimeFormat;
testGrid.Columns[3].DefaultCellStyle.Format = dtFormat doesn't work because it's not a string.
How do I crack this nut?
thanks for any help.
Try this:
testGrid.Columns[3].DefaultCellStyle.Format = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;