* UIComboBox: 修改失去焦点自动关闭过滤下拉框
This commit is contained in:
parent
9b57042d42
commit
ee328aa648
@ -445,7 +445,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle ControlBoxRect;
|
Rectangle ControlBoxRect;
|
||||||
public bool showClearButton;
|
protected bool showClearButton;
|
||||||
|
|
||||||
protected override void OnGotFocus(EventArgs e)
|
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();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
HideFilterForm();
|
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,18 +29,21 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.SuspendLayout();
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// edit
|
||||||
|
//
|
||||||
|
edit.Leave += edit_Leave;
|
||||||
//
|
//
|
||||||
// UIComboBox
|
// UIComboBox
|
||||||
//
|
//
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||||
this.Name = "UIComboBox";
|
Name = "UIComboBox";
|
||||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UIComboBox_KeyDown);
|
KeyDown += UIComboBox_KeyDown;
|
||||||
this.ButtonClick += new System.EventHandler(this.UIComboBox_ButtonClick);
|
ButtonClick += UIComboBox_ButtonClick;
|
||||||
this.FontChanged += new System.EventHandler(this.UIComboBox_FontChanged);
|
FontChanged += UIComboBox_FontChanged;
|
||||||
this.ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
this.PerformLayout();
|
PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
* 2022-11-13: V3.2.8 增加不显示过滤可以自动调整下拉框宽度
|
* 2022-11-13: V3.2.8 增加不显示过滤可以自动调整下拉框宽度
|
||||||
* 2022-11-30: V3.3.0 增加Clear方法
|
* 2022-11-30: V3.3.0 增加Clear方法
|
||||||
* 2023-02-04: V3.3.1 增加清除按钮
|
* 2023-02-04: V3.3.1 增加清除按钮
|
||||||
|
* 2023-03-15: V3.3.3 修改失去焦点自动关闭过滤下拉框
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -113,12 +114,6 @@ namespace Sunny.UI
|
|||||||
if (Text.IsNullOrEmpty() && ShowFilter)
|
if (Text.IsNullOrEmpty() && ShowFilter)
|
||||||
FillFilterTextEmpty();
|
FillFilterTextEmpty();
|
||||||
|
|
||||||
foreach (var item in Parent.GetControls<UIComboBox>())
|
|
||||||
{
|
|
||||||
if (!item.Equals(this))
|
|
||||||
item.HideFilterForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
FilterItemForm.AutoClose = false;
|
FilterItemForm.AutoClose = false;
|
||||||
if (!FilterItemForm.Visible)
|
if (!FilterItemForm.Visible)
|
||||||
{
|
{
|
||||||
@ -407,12 +402,6 @@ namespace Sunny.UI
|
|||||||
[Description("过滤时删除字符串前面、后面的空格"), Category("SunnyUI")]
|
[Description("过滤时删除字符串前面、后面的空格"), Category("SunnyUI")]
|
||||||
public bool TrimFilter { get; set; }
|
public bool TrimFilter { get; set; }
|
||||||
|
|
||||||
public void HideFilterForm()
|
|
||||||
{
|
|
||||||
if (FilterItemForm.Visible)
|
|
||||||
FilterItemForm.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FillFilterTextEmpty()
|
private void FillFilterTextEmpty()
|
||||||
{
|
{
|
||||||
filterForm.ListBox.Items.Clear();
|
filterForm.ListBox.Items.Clear();
|
||||||
@ -594,6 +583,20 @@ namespace Sunny.UI
|
|||||||
UIComboBox_ButtonClick(this, EventArgs.Empty);
|
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)]
|
[DefaultValue(false)]
|
||||||
[Description("不显示过滤可以自动调整下拉框宽度"), Category("SunnyUI")]
|
[Description("不显示过滤可以自动调整下拉框宽度"), Category("SunnyUI")]
|
||||||
public bool DropDownAutoWidth { get; set; }
|
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")]
|
[DefaultValue(typeof(Color), "White")]
|
||||||
public Color ItemFillColor
|
public Color ItemFillColor
|
||||||
{
|
{
|
||||||
|
@ -526,11 +526,6 @@ namespace Sunny.UI
|
|||||||
public virtual void Final()
|
public virtual void Final()
|
||||||
{
|
{
|
||||||
Finalize?.Invoke(this, new EventArgs());
|
Finalize?.Invoke(this, new EventArgs());
|
||||||
|
|
||||||
foreach (var item in this.GetControls<UIComboBox>(true))
|
|
||||||
{
|
|
||||||
item.HideFilterForm();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStyle(UIStyle style)
|
public void SetStyle(UIStyle style)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user