* UIComboBox: 修改失去焦点自动关闭过滤下拉框

This commit is contained in:
Sunny 2023-03-15 15:45:09 +08:00
parent 9b57042d42
commit ee328aa648
4 changed files with 33 additions and 28 deletions

View File

@ -445,7 +445,7 @@ namespace Sunny.UI
}
Rectangle ControlBoxRect;
public bool showClearButton;
protected bool showClearButton;
protected override void OnGotFocus(EventArgs e)
{

View File

@ -18,7 +18,6 @@
components.Dispose();
}
HideFilterForm();
base.Dispose(disposing);
}
@ -30,18 +29,21 @@
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
SuspendLayout();
//
// edit
//
edit.Leave += edit_Leave;
//
// UIComboBox
//
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);
this.PerformLayout();
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
Name = "UIComboBox";
KeyDown += UIComboBox_KeyDown;
ButtonClick += UIComboBox_ButtonClick;
FontChanged += UIComboBox_FontChanged;
ResumeLayout(false);
PerformLayout();
}
#endregion

View File

@ -34,6 +34,7 @@
* 2022-11-13: V3.2.8
* 2022-11-30: V3.3.0 Clear方法
* 2023-02-04: V3.3.1
* 2023-03-15: V3.3.3
******************************************************************************/
using System;
@ -113,12 +114,6 @@ namespace Sunny.UI
if (Text.IsNullOrEmpty() && ShowFilter)
FillFilterTextEmpty();
foreach (var item in Parent.GetControls<UIComboBox>())
{
if (!item.Equals(this))
item.HideFilterForm();
}
FilterItemForm.AutoClose = false;
if (!FilterItemForm.Visible)
{
@ -407,12 +402,6 @@ namespace Sunny.UI
[Description("过滤时删除字符串前面、后面的空格"), Category("SunnyUI")]
public bool TrimFilter { get; set; }
public void HideFilterForm()
{
if (FilterItemForm.Visible)
FilterItemForm.Close();
}
private void FillFilterTextEmpty()
{
filterForm.ListBox.Items.Clear();
@ -594,6 +583,20 @@ namespace Sunny.UI
UIComboBox_ButtonClick(this, EventArgs.Empty);
}
public void HideDropDown()
{
if (!ShowFilter)
{
if (dropForm != null && dropForm.Visible)
dropForm.Close();
}
else
{
if (FilterItemForm != null && FilterItemForm.Visible)
FilterItemForm.Close();
}
}
[DefaultValue(false)]
[Description("不显示过滤可以自动调整下拉框宽度"), Category("SunnyUI")]
public bool DropDownAutoWidth { get; set; }
@ -825,6 +828,11 @@ namespace Sunny.UI
}
}
private void edit_Leave(object sender, EventArgs e)
{
HideDropDown();
}
[DefaultValue(typeof(Color), "White")]
public Color ItemFillColor
{

View File

@ -526,11 +526,6 @@ namespace Sunny.UI
public virtual void Final()
{
Finalize?.Invoke(this, new EventArgs());
foreach (var item in this.GetControls<UIComboBox>(true))
{
item.HideFilterForm();
}
}
public void SetStyle(UIStyle style)