* UIComboBox: 增加过滤时忽略大小写
This commit is contained in:
parent
9679e2e9c2
commit
28cd82dc32
@ -35,6 +35,7 @@
|
||||
* 2022-11-30: V3.3.0 增加Clear方法
|
||||
* 2023-02-04: V3.3.1 增加清除按钮
|
||||
* 2023-03-15: V3.3.3 修改失去焦点自动关闭过滤下拉框
|
||||
* 2023-06-28: V3.3.9 增加过滤时忽略大小写
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -360,6 +361,16 @@ namespace Sunny.UI
|
||||
if (DataSource == null)
|
||||
{
|
||||
foreach (var item in Items)
|
||||
{
|
||||
if (FilterIgnoreCase)
|
||||
{
|
||||
if (item.ToString().ToUpper().Contains(filterText.ToUpper()))
|
||||
{
|
||||
filterList.Add(item.ToString());
|
||||
if (filterList.Count > FilterMaxCount) break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.ToString().Contains(filterText))
|
||||
{
|
||||
@ -368,11 +379,22 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dataManager != null)
|
||||
{
|
||||
for (int i = 0; i < Items.Count; i++)
|
||||
{
|
||||
if (FilterIgnoreCase)
|
||||
{
|
||||
if (GetItemText(dataManager.List[i]).ToString().ToUpper().Contains(filterText.ToUpper()))
|
||||
{
|
||||
filterList.Add(dataManager.List[i]);
|
||||
if (filterList.Count > FilterMaxCount) break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetItemText(dataManager.List[i]).ToString().Contains(filterText))
|
||||
{
|
||||
@ -382,6 +404,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in filterList)
|
||||
{
|
||||
@ -402,6 +425,10 @@ namespace Sunny.UI
|
||||
[Description("过滤时删除字符串前面、后面的空格"), Category("SunnyUI")]
|
||||
public bool TrimFilter { get; set; }
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Description("过滤时忽略大小写"), Category("SunnyUI")]
|
||||
public bool FilterIgnoreCase { get; set; }
|
||||
|
||||
private void FillFilterTextEmpty()
|
||||
{
|
||||
filterForm.ListBox.Items.Clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user