using System.Globalization; namespace System.Windows.Forms { public class DateTimePicker : Control { protected new CustomControls.DateTimePicker control { get; } private DateTimePickerFormat format; public DateTimePickerFormat Format { get => format; set { format = value; if (format == DateTimePickerFormat.Short) CustomFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; else if (format == DateTimePickerFormat.Long) CustomFormat = CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern; else if (format == DateTimePickerFormat.Time) CustomFormat = CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern; } } public string CustomFormat { get => format == DateTimePickerFormat.Custom ? control.CustomFormat : ""; set => control.CustomFormat = value; } public DateTime Value { get => control.Value ?? DateTime.MinValue; set => control.Value = value; } public DateTime MinDate { get => control.DisplayDateStart ?? DateTime.MinValue; set => control.DisplayDateStart = value; } public DateTime MaxDate { get => control?.DisplayDateEnd ?? DateTime.MaxValue; set => control.DisplayDateEnd = value; } public bool ShowCheckBox { get; set; } public bool ShowUpDown { get; set; } public LeftRightAlignment DropDownAlign { get; set; } public bool Checked { get; set; } public event EventHandler ValueChanged; protected override void SetControlHeight(int value) { // ignore height } public DateTimePicker() { control = new(); SetControl(control); control.SelectedDateChanged += (sender,e) => ValueChanged?.Invoke(this, EventArgs.Empty); BackColor = System.Drawing.SystemColors.Window; Width = 200; Format = DateTimePickerFormat.Long; } } }