如何在 Winform 应用程序中设置应用程序范围的文化信息
我试图在我的一个 winform 应用程序(VB .net)的开头设置文化信息。代码是:
Public Sub New()
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-CA")
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en-CA")
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
但是,后续表单中的日期时间选择器显示“dd-MM-yyyy”类型的日期格式。怎样才能设置正确呢?我缺少什么步骤。
I trying to set cultural information at the beginning of one of my winform application (VB .net). The code are:
Public Sub New()
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-CA")
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en-CA")
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
However, datetime picker in the subsequent form shows date format of the type "dd-MM-yyyy". How can I set is right? What steps I am missing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,新线程的默认区域性没有应用程序范围的设置。线程的默认区域性是由 Windows 在创建时设置的。
另请查看此知识库文章< /a>,虽然很旧,但我相信仍然适用。 DatePicker 使用 Windows 区域设置而不是 currentCulture。
您可以直接更改 DatePicker 的设置以使其按您的意愿显示。
比如:
我想如果我有很多这样的东西,我可能会创建自己的类来继承 DatePicker 并在构造函数中设置它。
Unfortunately there's no application-wide setting for the default culture for new threads. The default culture of a thread is set by Windows when it is created.
Also check out this KB Article, which is old but I believe still applies. The DatePicker uses windows regional settings rather than currentCulture.
You can alter the settings for a DatePicker directly to make it display as you wish.
Something like:
I think if I had many of these I may make my own class to inherit from DatePicker and set that in the constructor.