* UIComboDataGridView: 过滤时删除字符串前面、后面的空格

This commit is contained in:
Sunny 2022-11-03 17:04:39 +08:00
parent 655c098177
commit 94ad1bad69
2 changed files with 16 additions and 4 deletions

View File

@ -26,6 +26,8 @@ namespace Sunny.UI
edtFilter.TextChanged += EdtFilter_TextChanged;
}
public bool TrimFilter { get; set; }
private void EdtFilter_TextChanged(object sender, System.EventArgs e)
{
btnSearch_Click(null, null);
@ -341,7 +343,11 @@ namespace Sunny.UI
private void btnSearch_Click(object sender, System.EventArgs e)
{
string filter = "";
if (edtFilter.Text.IsNullOrEmpty())
string filterText = edtFilter.Text;
if (TrimFilter)
filterText = filterText.Trim();
if (filterText.IsNullOrEmpty())
{
filter = "";
}
@ -349,7 +355,7 @@ namespace Sunny.UI
{
if (FilterColumnName.IsValid())
{
string str = FilterColumnName + " like '%" + edtFilter.Text + "%'";
string str = FilterColumnName + " like '%" + filterText + "%'";
filter = str;
}
else
@ -359,7 +365,7 @@ namespace Sunny.UI
{
if (column.Visible && column.DataPropertyName.IsValid())
{
strings.Add(column.DataPropertyName + " like '%" + edtFilter.Text + "%'");
strings.Add(column.DataPropertyName + " like '%" + filterText + "%'");
}
}
@ -380,7 +386,7 @@ namespace Sunny.UI
}
}
ComboDataGridViewFilterChanged?.Invoke(this, new UIComboDataGridViewArgs(edtFilter.Text, dataGridView.RowCount));
ComboDataGridViewFilterChanged?.Invoke(this, new UIComboDataGridViewArgs(filterText, dataGridView.RowCount));
}
private void btnClear_Click(object sender, System.EventArgs e)

View File

@ -23,6 +23,7 @@
* 2022-06-16: V3.2.0
* 2022-06-19: V3.2.0 FilterChanged
* 2022-09-08: V3.2.3
* 2022-11-03: V3.2.6
******************************************************************************/
using System;
@ -51,6 +52,10 @@ namespace Sunny.UI
this.PerformLayout();
}
[DefaultValue(false)]
[Description("过滤时删除字符串前面、后面的空格"), Category("SunnyUI")]
public bool TrimFilter { get; set; }
public event OnComboDataGridViewFilterChanged FilterChanged;
[DefaultValue(500)]
@ -63,6 +68,7 @@ namespace Sunny.UI
private void UIComboDataGridView_ButtonClick(object sender, EventArgs e)
{
item.TrimFilter = TrimFilter;
item.FilterColumnName = FilterColumnName;
item.ShowFilter = ShowFilter;
ItemForm.Size = ItemSize;