diff --git a/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs b/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs index 5fda19b7..59e24a3b 100644 --- a/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs +++ b/SunnyUI/Controls/DropItem/UIComboBoxItem.Designer.cs @@ -28,38 +28,38 @@ /// private void InitializeComponent() { - this.listBox = new Sunny.UI.UIListBox(); - this.SuspendLayout(); + listBox = new UIListBox(); + SuspendLayout(); // // listBox // - this.listBox.BackColor = System.Drawing.Color.Transparent; - this.listBox.Dock = System.Windows.Forms.DockStyle.Fill; - 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.Size = new System.Drawing.Size(184, 210); - this.listBox.TabIndex = 3; - this.listBox.Text = null; - this.listBox.Click += 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); + listBox.BackColor = System.Drawing.Color.Transparent; + listBox.Dock = System.Windows.Forms.DockStyle.Fill; + listBox.FillColor = System.Drawing.Color.White; + listBox.Font = new System.Drawing.Font("宋体", 12F); + listBox.HoverColor = System.Drawing.Color.FromArgb(155, 200, 255); + listBox.ItemSelectForeColor = System.Drawing.Color.FromArgb(235, 243, 255); + listBox.Location = new System.Drawing.Point(0, 0); + listBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + listBox.MinimumSize = new System.Drawing.Size(1, 1); + listBox.Name = "listBox"; + listBox.Padding = new System.Windows.Forms.Padding(2); + listBox.Radius = 0; + listBox.ShowText = false; + listBox.Size = new System.Drawing.Size(184, 210); + listBox.TabIndex = 3; + listBox.Text = null; + listBox.KeyDown += listBox_KeyDown; + listBox.Click += ListBox_Click; + listBox.SelectedIndexChanged += listBox_SelectedIndexChanged; // // UIComboBoxItem // - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; - this.Controls.Add(this.listBox); - this.Name = "UIComboBoxItem"; - this.Size = new System.Drawing.Size(184, 210); - this.ResumeLayout(false); - + AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + Controls.Add(listBox); + Name = "UIComboBoxItem"; + Size = new System.Drawing.Size(184, 210); + ResumeLayout(false); } #endregion diff --git a/SunnyUI/Controls/DropItem/UIComboBoxItem.resx b/SunnyUI/Controls/DropItem/UIComboBoxItem.resx index f298a7be..8b2ff64a 100644 --- a/SunnyUI/Controls/DropItem/UIComboBoxItem.resx +++ b/SunnyUI/Controls/DropItem/UIComboBoxItem.resx @@ -1,4 +1,64 @@ - + + + diff --git a/SunnyUI/Controls/UIComboBox.cs b/SunnyUI/Controls/UIComboBox.cs index 1f997564..a78265c6 100644 --- a/SunnyUI/Controls/UIComboBox.cs +++ b/SunnyUI/Controls/UIComboBox.cs @@ -40,6 +40,7 @@ * 2023-08-11: V3.4.1 Items.Clear后,DropDownStyle为DropDown时,不清空Text * 2023-12-26: V3.6.2 增加下拉界面的滚动条设置 * 2024-01-27: V3.6.3 修复在窗体构造函数设置SelectedIndex报错 + * 2024-10-28: V3.7.2 增加了SelectionChangeCommitted事件,下拉框显示鼠标点击条目时响应 ******************************************************************************/ using System; @@ -71,6 +72,7 @@ namespace Sunny.UI ListBox.SelectedValueChanged += ListBox_SelectedValueChanged; ListBox.ItemsClear += ListBox_ItemsClear; ListBox.ItemsRemove += ListBox_ItemsRemove; + ListBox.MouseClick += ListBox_MouseClick; filterForm.BeforeListClick += ListBox_Click; @@ -82,6 +84,19 @@ namespace Sunny.UI CreateInstance(); } + private void ListBox_MouseClick(object sender, MouseEventArgs e) + { + //SelectionChangeCommitted + UIListBox listBox = (UIListBox)sender; + int index = listBox.IndexFromPoint(e.X, e.Y); + if (index != -1) + { + SelectionChangeCommitted?.Invoke(this, EventArgs.Empty); + } + } + + public event EventHandler SelectionChangeCommitted; + [Browsable(false)] public override string[] FormTranslatorProperties { get; }