使用CultureInfo自定义格式化DateTimePicker [英] Custom Formating a DateTimePicker using CultureInfo

查看:261
本文介绍了使用CultureInfo自定义格式化DateTimePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Vb.Net Windows项目中使用了DateTimePicker控件。



我希望日期反映用户计算机上的区域设置,但也可以显示月份名称,而不是月份号码。



例如,如果我的电脑设置为英文(美国),我希望看到2009年11月26日如果我的电脑设置为英语(NZ),我希望看到2009年11月26日



这是可能的吗?



我知道我可以将CustomFormat属性设置为dd MMM yyyy,但是这样总是显示2009年11月26日,即使是英语(US)的区域设置也是如此。

有没有办法可以使用CultureInfo.CurrentCulture来设置所有文化的日期? (即不只是一个基于CurrentCulture设置CustomFormat的select case语句)。
$ b $ p

感谢。

解决方案

在CodeProject上看到这个新的文章可能有帮助:

文化感知月日历和日期选择器



请注意,控件是用C#你可以在你的VB项目中使用这个DLL。

它看起来像你需要的,虽然我还没有尝试过。


I am using the DateTimePicker control in a Vb.Net Windows project.

I would like the date to reflect the Regional Settings on the user's computer, but also to show the month name, rather than the month number.

For example, if my computer is set to English(US), I would like to see Nov 26 2009, and if my computer is set to English (NZ), I would like to see 26 Nov 2009

Is this possible?

I know that I can set the CustomFormat property to say "dd MMM yyyy", but then that always shows 26 Nov 2009, even with the regional setting of English(US).

Is there someway I can use the CultureInfo.CurrentCulture to set the date for all cultures? (i.e. not just a select case statement that sets the CustomFormat based on the CurrentCulture).

Thanks.

解决方案

Saw this new article on CodeProject that may help:

Culture Aware Month Calendar and Datepicker

Note that control is in C#, but of course you can use the DLL in your VB project.

It looks like what you need though I haven't tried it.

这篇关于使用CultureInfo自定义格式化DateTimePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆