DevExpress的GridControl的过滤器的自定义过滤

例如有一列
101
10
01
02
用"*0"就能查出来这4个数据
用"0"就只能查出01和02
怎么输入一个“0”就能把这四个输出一起查询出来,以下是自己憋了一天才找到的办法

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DifferentialBackup
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            string sql = "select top 100 * from pub_dict";
            gridControl1.DataSource = SqlHelper.GetDataTable(sql, CommandType.Text);
        }

        private void gridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            FuzzyQuery();
        }

        private void FuzzyQuery()
        {
            string newFilter = string.Empty;
            string filter = gridView1.ActiveFilterString;
            newFilter = filter.Replace("StartsWith", "Contains");
            gridView1.ActiveFilterString = newFilter;
        }
    }
}

转载于:https://my.oschina.net/dongri/blog/610897

猜你喜欢

转载自blog.csdn.net/weixin_34203832/article/details/91765900