开发者

Datagridview DateTime Format not using System Region settings

I've got a datagri开发者_运维问答dview that is hooked up to a bindingsource on my main form. One of the columns and datamembers in the bindingsource is a DateTime object. When the datagridview shows this item it doesn't use Window's default region settings for displaying datetime.

The weird thing is, I can access this same DateTime object and print it to a text box, or even pass it off to another form with another datagridview and binding source and it actually shows up properly in that table.

So then, why does the datagridview on my main form not use the regional date/time settings when converting the DateTime object to a string?

I've checked that there was no special formatting applied to the datagridview and so I'm running out of ideas to check.

Do you guys know if there is any super secret way to get a datagridview to follow system regional format rules or not?

Also, since I highly doubt that I did something different with this datagridview vs the others in my application, the next potential area for issue could be on application load: Perhaps since this comes up when the application loads, it's not getting the same cultureUI settings as the other datagridviews?

Update I've tried adding another column to the datagrid view and hooking it up to the same data property (datetime) and I get the same result. So something about how entire datagridview, or how it was created is stopping the "ToString" from using the default regional settings.

Any Help?


On design, in the Edit Columns dialog of the DataGridView:

  1. Search for property DefaultCellStyle, and open this dialog;
  2. Search for property Format and choose Date format;
  3. Choose your favorite format.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜