日期时间控件(DateTimePicker)在时间控件中的应用最多,主要用于在界面上显示当前的时间。
Format 属性提供了 4 个属性值,如下所示。
Short:短日期格式,例如2017/3/1;
Long:长日期格式,例如2017年3月1日;
Time:仅显示时间,例如,22:00:01;
Custom:用户自定义的显示格式。
注意:
如果将 Format 属性设置为 Custom 值,则需要通过设置 CustomFormat 属性值来自定义显示日期时间的格式。
【实例】
在窗体上设置动态的日期时间(使用定时器)。
DataTimePickerFrom.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using Sys