试试看我的代码,可以用 % 符号查询!
- private void c1Grid_Filter(object sender, FilterEventArgs e)
- {
- var dataView = ((DataTable)c1Grid.DataSource).DefaultView;
- if (dataView.RowFilter == e.Condition)
- {
- return;
- }
- var condition = e.Condition;
- if (condition.Length != 0)
- {
- condition = e.Condition;
- for (var i = 0; i < c1Grid.Splits[0].DisplayColumns.Count; i++)
- {
- if (!condition.Contains($"[{c1Grid.Columns[i].Caption}]"))
- {
- continue;
- }
- var paramIndex = condition.IndexOf('\'', condition.IndexOf($"[{c1Grid.Columns[i].Caption}]", StringComparison.Ordinal)) + 1;
- condition = condition.Insert(paramIndex, "*");
- }
- }
- dataView.RowFilter = condition;
- }
复制代码
|