diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 1c02fcbc..a86347a6 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net462/SunnyUI.dll b/Bin/net462/SunnyUI.dll index 33148dc2..259f286e 100644 Binary files a/Bin/net462/SunnyUI.dll and b/Bin/net462/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index fdd7774c..787109b0 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index 21d46ffe..bb90a85e 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index e818b721..60e3b45b 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs b/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs index 473d8b74..d4b571ba 100644 --- a/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs +++ b/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs @@ -35,26 +35,25 @@ // this.listBox.BackColor = System.Drawing.Color.Transparent; this.listBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.listBox.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.listBox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); - this.listBox.ItemSelectBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255))))); + this.listBox.FillColor = System.Drawing.Color.White; + this.listBox.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.listBox.FormatString = ""; this.listBox.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); this.listBox.Location = new System.Drawing.Point(0, 0); this.listBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.listBox.MinimumSize = new System.Drawing.Size(1, 1); this.listBox.Name = "listBox"; this.listBox.Padding = new System.Windows.Forms.Padding(2); this.listBox.Radius = 0; - this.listBox.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255))))); this.listBox.Size = new System.Drawing.Size(184, 210); - this.listBox.Style = Sunny.UI.UIStyle.Custom; this.listBox.TabIndex = 3; this.listBox.Text = null; this.listBox.ItemClick += new System.EventHandler(this.ListBox_Click); this.listBox.SelectedIndexChanged += new System.EventHandler(this.listBox_SelectedIndexChanged); + this.listBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listBox_KeyDown); // // UIComboBoxItem // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.Controls.Add(this.listBox); this.Name = "UIComboBoxItem"; diff --git a/SunnyUI/Controls/DropItem/UIComboBoxItem.cs b/SunnyUI/Controls/DropItem/UIComboBoxItem.cs index d759080c..bc271c0c 100644 --- a/SunnyUI/Controls/DropItem/UIComboBoxItem.cs +++ b/SunnyUI/Controls/DropItem/UIComboBoxItem.cs @@ -69,5 +69,13 @@ namespace Sunny.UI { DoValueChanged(this, ListBox.SelectedValue); } + + private void listBox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) + { + if (e.KeyCode == System.Windows.Forms.Keys.Enter || e.KeyCode == System.Windows.Forms.Keys.Space) + { + CloseParent(); + } + } } } \ No newline at end of file diff --git a/SunnyUI/Controls/DropItem/UIComboBoxItem.resx b/SunnyUI/Controls/DropItem/UIComboBoxItem.resx index 1af7de15..f298a7be 100644 --- a/SunnyUI/Controls/DropItem/UIComboBoxItem.resx +++ b/SunnyUI/Controls/DropItem/UIComboBoxItem.resx @@ -1,64 +1,4 @@ - - - + diff --git a/SunnyUI/Controls/UIComboBox.Designer.cs b/SunnyUI/Controls/UIComboBox.Designer.cs index f4caae15..2f0a24f5 100644 --- a/SunnyUI/Controls/UIComboBox.Designer.cs +++ b/SunnyUI/Controls/UIComboBox.Designer.cs @@ -30,11 +30,15 @@ { this.SuspendLayout(); // + // edit + // + this.edit.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edit_KeyDown); + // // UIComboBox // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.Name = "UIComboBox"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UIComboBox_KeyDown); this.ButtonClick += new System.EventHandler(this.UIComboBox_ButtonClick); this.FontChanged += new System.EventHandler(this.UIComboBox_FontChanged); this.ResumeLayout(false); diff --git a/SunnyUI/Controls/UIComboBox.cs b/SunnyUI/Controls/UIComboBox.cs index ec454aa4..ac245311 100644 --- a/SunnyUI/Controls/UIComboBox.cs +++ b/SunnyUI/Controls/UIComboBox.cs @@ -36,7 +36,7 @@ namespace Sunny.UI [DefaultEvent("SelectedIndexChanged")] [ToolboxItem(true)] [LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")] - public sealed partial class UIComboBox : UIDropControl,IToolTip + public sealed partial class UIComboBox : UIDropControl, IToolTip { public UIComboBox() { @@ -193,6 +193,11 @@ namespace Sunny.UI } } + public void ShowDropDown() + { + UIComboBox_ButtonClick(this, EventArgs.Empty); + } + private void UIComboBox_ButtonClick(object sender, EventArgs e) { if (Items.Count > 0) @@ -313,5 +318,21 @@ namespace Sunny.UI { return ListBox.GetItemText(item); } + + private void UIComboBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == System.Windows.Forms.Keys.Enter) + { + ShowDropDown(); + } + } + + private void edit_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == System.Windows.Forms.Keys.Enter) + { + ShowDropDown(); + } + } } } \ No newline at end of file diff --git a/SunnyUI/Controls/UIComboBox.resx b/SunnyUI/Controls/UIComboBox.resx index 1af7de15..f298a7be 100644 --- a/SunnyUI/Controls/UIComboBox.resx +++ b/SunnyUI/Controls/UIComboBox.resx @@ -1,64 +1,4 @@ - - - + diff --git a/SunnyUI/Controls/UIListBox.cs b/SunnyUI/Controls/UIListBox.cs index f0cd5161..9717e4a0 100644 --- a/SunnyUI/Controls/UIListBox.cs +++ b/SunnyUI/Controls/UIListBox.cs @@ -37,7 +37,7 @@ namespace Sunny.UI { [DefaultEvent("ItemClick")] [DefaultProperty("Items")] - public sealed partial class UIListBox : UIPanel,IToolTip + public sealed partial class UIListBox : UIPanel, IToolTip { private readonly ListBoxEx listbox = new ListBoxEx(); private readonly UIScrollBar bar = new UIScrollBar(); @@ -78,11 +78,33 @@ namespace Sunny.UI listbox.ItemsAdd += Listbox_ItemsAdd; listbox.ItemsRemove += Listbox_ItemsRemove; listbox.ItemsInsert += Listbox_ItemsInsert; + listbox.KeyPress += Listbox_KeyPress; + listbox.KeyDown += Listbox_KeyDown; + listbox.KeyUp += Listbox_KeyUp; timer.Tick += Timer_Tick; timer.Start(); } + public new event KeyPressEventHandler KeyPress; + public new event KeyEventHandler KeyDown; + public new event KeyEventHandler KeyUp; + + private void Listbox_KeyUp(object sender, KeyEventArgs e) + { + KeyUp?.Invoke(this, e); + } + + private void Listbox_KeyDown(object sender, KeyEventArgs e) + { + KeyDown?.Invoke(this, e); + } + + private void Listbox_KeyPress(object sender, KeyPressEventArgs e) + { + KeyPress?.Invoke(this, e); + } + public Control ExToolTipControl() { return listbox; diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj index decf40f2..b44df195 100644 --- a/SunnyUI/SunnyUI.csproj +++ b/SunnyUI/SunnyUI.csproj @@ -1,50 +1,50 @@  - net5.0-windows;netcoreapp3.1;net462;net40 + net5.0-windows;netcoreapp3.1;net462;net40 9.0 - {AB1CB247-E20B-4CBE-B269-570ADDD96C53} - true - Sunny.UI - SunnyUI.Net 是基于.Net Framework 4.0+、.Net Core3.1、.Net 5 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。 - CopyRight © SunnyUI.Net 2012-2021 - LICENSE - 3.0.6 - ShenYonghua - SunnyUI.Net - SunnyUI - https://gitee.com/yhuse/SunnyUI - https://gitee.com/yhuse/SunnyUI - false - false - SunnyUI.png + {AB1CB247-E20B-4CBE-B269-570ADDD96C53} + true + Sunny.UI + SunnyUI.Net 是基于.Net Framework 4.0+、.Net Core3.1、.Net 5 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。 + CopyRight © SunnyUI.Net 2012-2021 + LICENSE + 3.0.6 + ShenYonghua + SunnyUI.Net + SunnyUI + https://gitee.com/yhuse/SunnyUI + https://gitee.com/yhuse/SunnyUI + false + false + SunnyUI.png - ..\Bin\ - true - + ..\Bin\ + true + - ..\Bin\ - true - + ..\Bin\ + true + - false + false - + True - - + + True - + @@ -56,13 +56,13 @@ - + - - - + + + @@ -73,9 +73,9 @@ - True - True - Resources.resx + True + True + Resources.resx @@ -83,7 +83,7 @@ ResXFileCodeGenerator - Resources.Designer.cs + Resources.Designer.cs