简体   繁体   English

C#WinForms DateTimePicker组件

[英]C# WinForms DateTimePicker Component

I m using DateTimePicker component. 我正在使用DateTimePicker组件。 Does is possible tu change format ? 可能会转换格式吗? I Want to be YYYY-MM-DD. 我想成为YYYY-MM-DD。 This componenet default format is MM/DD/YYYY 此componenet默认格式为MM / DD / YYYY

Thanks . 谢谢 。 I love you Guys :D 我爱你们:D

You need to set the CustomFormat property to yyyy-MM-dd . 您需要将CustomFormat属性设置为yyyy-MM-dd
You'll also need to set Format to Custom . 您还需要将Format设置为Custom

Yes, use CustomFormat to specify the format you want. 是的,使用CustomFormat指定所需的格式。 Do be aware that the picker uses the user's regional settings by default for the format, so you might not want to set it yourself (if you care about internationalization). 请注意,选择器默认使用用户的区域设置作为格式,因此您可能不想自己进行设置(如果您关心国际化的话)。

MSDN reference MSDN参考

  public void SetMyCustomFormat()
    {
       // Set the Format type and the CustomFormat string.
       dateTimePicker1.Format = DateTimePickerFormat.Custom;
       dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd";
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM