* UIComboBox: 修改失去焦点自动关闭过滤下拉框
This commit is contained in:
parent
9b57042d42
commit
ee328aa648
@ -445,7 +445,7 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
Rectangle ControlBoxRect;
|
||||
public bool showClearButton;
|
||||
protected bool showClearButton;
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
|
22
SunnyUI/Controls/UIComboBox.Designer.cs
generated
22
SunnyUI/Controls/UIComboBox.Designer.cs
generated
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user