简体   繁体   中英

C# DateTimePicker Custom Format

How do I set a DateTimePicker to out put dd/mm/yyyy.

At the moment it is giving me the day, date, month then year.

Thanks.

dateTimePicker1.CustomFormat = "dd/MM/yyyy";
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "dd/MM/yyyy";
dateTimePicker1.Format = DateTimePickerFormat.Custom;

您需要将属性DateTimePicker.Format设置为DateTimePickerFormat.Custom并在DateTimePicker.CustomFormat属性中设置所需的格式。

        // Set the Format type and the CustomFormat string.
        dtpDeliveryDate.Format = DateTimePickerFormat.Custom;
        dtpDeliveryDate.CustomFormat = "dd-MM-yyyy";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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