* UIComboDataGridView: 过滤时删除字符串前面、后面的空格
This commit is contained in:
parent
655c098177
commit
94ad1bad69
@ -26,6 +26,8 @@ namespace Sunny.UI
|
|||||||
edtFilter.TextChanged += EdtFilter_TextChanged;
|
edtFilter.TextChanged += EdtFilter_TextChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TrimFilter { get; set; }
|
||||||
|
|
||||||
private void EdtFilter_TextChanged(object sender, System.EventArgs e)
|
private void EdtFilter_TextChanged(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
btnSearch_Click(null, null);
|
btnSearch_Click(null, null);
|
||||||
@ -341,7 +343,11 @@ namespace Sunny.UI
|
|||||||
private void btnSearch_Click(object sender, System.EventArgs e)
|
private void btnSearch_Click(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
string filter = "";
|
string filter = "";
|
||||||
if (edtFilter.Text.IsNullOrEmpty())
|
string filterText = edtFilter.Text;
|
||||||
|
if (TrimFilter)
|
||||||
|
filterText = filterText.Trim();
|
||||||
|
|
||||||
|
if (filterText.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
filter = "";
|
filter = "";
|
||||||
}
|
}
|
||||||
@ -349,7 +355,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (FilterColumnName.IsValid())
|
if (FilterColumnName.IsValid())
|
||||||
{
|
{
|
||||||
string str = FilterColumnName + " like '%" + edtFilter.Text + "%'";
|
string str = FilterColumnName + " like '%" + filterText + "%'";
|
||||||
filter = str;
|
filter = str;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -359,7 +365,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (column.Visible && column.DataPropertyName.IsValid())
|
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)
|
private void btnClear_Click(object sender, System.EventArgs e)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
* 2022-06-16: V3.2.0 增加下拉框宽度、高度
|
* 2022-06-16: V3.2.0 增加下拉框宽度、高度
|
||||||
* 2022-06-19: V3.2.0 增加FilterChanged,输出过滤文字和记录条数
|
* 2022-06-19: V3.2.0 增加FilterChanged,输出过滤文字和记录条数
|
||||||
* 2022-09-08: V3.2.3 增加过滤字异常判断
|
* 2022-09-08: V3.2.3 增加过滤字异常判断
|
||||||
|
* 2022-11-03: V3.2.6 过滤时删除字符串前面、后面的空格
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -51,6 +52,10 @@ namespace Sunny.UI
|
|||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DefaultValue(false)]
|
||||||
|
[Description("过滤时删除字符串前面、后面的空格"), Category("SunnyUI")]
|
||||||
|
public bool TrimFilter { get; set; }
|
||||||
|
|
||||||
public event OnComboDataGridViewFilterChanged FilterChanged;
|
public event OnComboDataGridViewFilterChanged FilterChanged;
|
||||||
|
|
||||||
[DefaultValue(500)]
|
[DefaultValue(500)]
|
||||||
@ -63,6 +68,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void UIComboDataGridView_ButtonClick(object sender, EventArgs e)
|
private void UIComboDataGridView_ButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
item.TrimFilter = TrimFilter;
|
||||||
item.FilterColumnName = FilterColumnName;
|
item.FilterColumnName = FilterColumnName;
|
||||||
item.ShowFilter = ShowFilter;
|
item.ShowFilter = ShowFilter;
|
||||||
ItemForm.Size = ItemSize;
|
ItemForm.Size = ItemSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user