0

We have a gridview in a c# winapp that keeps on showing the dates in the US format, and we would like to use the local PC's date format. How can we change it:

myDataTable.Columns.Add("Time", typeof(DateTime));
myGrid.DataSource = myDataTable;
myGrid.Columns["Time"].DisplayFormat.FormatString = "g";
Cameron Castillo
  • 2,712
  • 10
  • 47
  • 77
  • Where do you get the local PC's culture? – SelvaS Mar 18 '15 at 14:26
  • What is your `CurrentCulture`? What do you see results right now and which format do you want to see them exactly? – Soner Gönül Mar 18 '15 at 14:29
  • My local culture is en-ZA, but the app will also run on other countries, so en-GB will also be used. – Cameron Castillo Mar 18 '15 at 14:35
  • It shows the Time column as 3/18/2015 09:10:30, and I would like to see 2015/03/15 09:10:30, but when deployed in GB or US, it should use the local settings as per the PC's settings in control panel. – Cameron Castillo Mar 18 '15 at 14:38
  • 1
    see here: http://stackoverflow.com/questions/1542409/how-to-get-current-regional-settings-in-c for how to get the Culture settings. Once you have that, converting dates is rather straightforward – guildsbounty Mar 18 '15 at 14:42
  • @user1208908 Are you using devexpress? – Soner Gönül Mar 18 '15 at 14:45
  • Yes, I'm using dev express. – Cameron Castillo Mar 19 '15 at 06:41
  • @guildsbounty the link helps to reset the culture info but for some strange reason I can't seem to set the DisplayFormat.FormatString as the samples are all different than setting a column format. Will keep on searching through the wide web, but any ideas or samples will be great and appreciated. – Cameron Castillo Mar 19 '15 at 07:03

0 Answers0