• Winform Combox 下拉模糊匹配


    combox 自动匹配可以设置两个属性:

    cmbProdList.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
    cmbProdList.AutoCompleteSource = AutoCompleteSource.ListItems;

    设置后可以自动匹配,但不能模糊匹配。

    下面是自己实现模糊匹配方法,实际上用到DataView 过滤功能,重新绑定数据,就这么简单。

    private void cmbProdList_TextChanged(object sender, EventArgs e)

    {
    string keys = cmbProdList.Text.Trim();
    if (keys.Length > 0)
    {
    UserList.RowFilter = " Title LIKE '*" + keys + "*'";
    cmbProdList.DroppedDown = true;
    }
    cmbProdList.DataSource = UserList;
    cmbProdList.DisplayMember = "Title";
    cmbProdList.ValueMember = "Id";
    Cursor.Current = Cursors.Default;//设置鼠标显示
    //cmbProdList.Refresh();
    }

  • 相关阅读:
    Bessie Goes Moo
    小P的强力值
    Max Flow
    约瑟夫
    Moocryption
    杂务
    排行榜
    银行贷款
    轰炸
    Contaminated Milk
  • 原文地址:https://www.cnblogs.com/lanyue52011/p/2800367.html
Copyright © 2020-2023  润新知