diff --git a/Bin/SunnyUI.Demo.exe b/Bin/SunnyUI.Demo.exe index 643f37a2..524f1fa3 100644 Binary files a/Bin/SunnyUI.Demo.exe and b/Bin/SunnyUI.Demo.exe differ diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index eba15a47..e7e5ef34 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FCombobox.Designer.cs b/SunnyUI.Demo/Controls/FCombobox.Designer.cs index 6c0bcaf1..236ae6b3 100644 --- a/SunnyUI.Demo/Controls/FCombobox.Designer.cs +++ b/SunnyUI.Demo/Controls/FCombobox.Designer.cs @@ -127,6 +127,7 @@ // // uiDatetimePicker1 // + this.uiDatetimePicker1.CanEmpty = true; this.uiDatetimePicker1.FillColor = System.Drawing.Color.White; this.uiDatetimePicker1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiDatetimePicker1.Location = new System.Drawing.Point(388, 136); @@ -184,6 +185,7 @@ // // uiTimePicker1 // + this.uiTimePicker1.CanEmpty = true; this.uiTimePicker1.FillColor = System.Drawing.Color.White; this.uiTimePicker1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiTimePicker1.Location = new System.Drawing.Point(188, 136); @@ -225,6 +227,7 @@ // // uiDatePicker1 // + this.uiDatePicker1.CanEmpty = true; this.uiDatePicker1.FillColor = System.Drawing.Color.White; this.uiDatePicker1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiDatePicker1.Location = new System.Drawing.Point(30, 136); diff --git a/SunnyUI/Controls/UIComboBox.cs b/SunnyUI/Controls/UIComboBox.cs index c9499db4..7331cd55 100644 --- a/SunnyUI/Controls/UIComboBox.cs +++ b/SunnyUI/Controls/UIComboBox.cs @@ -83,6 +83,7 @@ namespace Sunny.UI protected override void ItemForm_ValueChanged(object sender, object value) { SelectedIndex = ListBox.SelectedIndex; + Box_SelectedIndexChanged(null, null); Invalidate(); } diff --git a/SunnyUI/Controls/UIDatePicker.cs b/SunnyUI/Controls/UIDatePicker.cs index 056ea388..ab14f9fb 100644 --- a/SunnyUI/Controls/UIDatePicker.cs +++ b/SunnyUI/Controls/UIDatePicker.cs @@ -41,6 +41,10 @@ namespace Sunny.UI TextChanged += UIDatePicker_TextChanged; } + [DefaultValue(false)] + [Description("日期输入时,是否可空显示"), Category("SunnyUI")] + public bool CanEmpty { get; set; } + private void UIDatePicker_TextChanged(object sender, EventArgs e) { if (Text.Length == MaxLength) @@ -59,6 +63,11 @@ namespace Sunny.UI private void UIDatePicker_LostFocus(object sender, EventArgs e) { + if (Text.IsNullOrEmpty()) + { + if (CanEmpty) return; + } + try { DateTime dt = Text.ToDateTime(DateFormat); diff --git a/SunnyUI/Controls/UIDateTimePicker.cs b/SunnyUI/Controls/UIDateTimePicker.cs index 1867142b..94d0a7ae 100644 --- a/SunnyUI/Controls/UIDateTimePicker.cs +++ b/SunnyUI/Controls/UIDateTimePicker.cs @@ -48,6 +48,10 @@ namespace Sunny.UI } + [DefaultValue(false)] + [Description("日期输入时,是否可空显示"), Category("SunnyUI")] + public bool CanEmpty { get; set; } + public UIDatetimePicker() { InitializeComponent(); @@ -77,6 +81,11 @@ namespace Sunny.UI private void UIDatePicker_LostFocus(object sender, EventArgs e) { + if (Text.IsNullOrEmpty()) + { + if (CanEmpty) return; + } + try { DateTime dt = Text.ToDateTime(DateFormat); diff --git a/SunnyUI/Controls/UITimePicker.cs b/SunnyUI/Controls/UITimePicker.cs index 619775c1..a5ed0c9d 100644 --- a/SunnyUI/Controls/UITimePicker.cs +++ b/SunnyUI/Controls/UITimePicker.cs @@ -56,6 +56,10 @@ namespace Sunny.UI MaxLength = 8; } + [DefaultValue(false)] + [Description("日期输入时,是否可空显示"), Category("SunnyUI")] + public bool CanEmpty { get; set; } + private void UIDatePicker_TextChanged(object sender, EventArgs e) { if (Text.Length == MaxLength) @@ -74,6 +78,11 @@ namespace Sunny.UI private void UIDatePicker_LostFocus(object sender, EventArgs e) { + if (Text.IsNullOrEmpty()) + { + if (CanEmpty) return; + } + try { DateTime dt = (DateTime.Now.DateString() + " " + Text).ToDateTime(DateTimeEx.DateFormat + " " + timeFormat);