zoukankan      html  css  js  c++  java
  • DevExpress控件TExtLookupComboBox实现多列模糊匹配输入的方法

    本方案不需要修改控件源码,是完美解决支持多列模糊匹配快速输入的最佳方案!!

     

    1、把列的Properties属性设置为ExtLookupComboBox。

    Properties.IncrementalFiltering := False;
    Properties.CaseSensitiveSearch := False; 
    Properties.DropDownListStyle := lsEditList;

    当然,接着要完成设置Properties.View,Properties.KeyFieldNames和Properties.ListFieldItem。

      // 本案例的列是:cxGridDBTableView1VENDOR_ID: TcxGridDBColumn;绑定服务商ID自动。

    2、Properties.OnChange事件代码:

    procedure TFormcxLookupCombox.cxGridDBTableView1VENDOR_IDPropertiesChange(Sender: TObject);

    var
      iCol: Integer;
      vInputText: String;
    begin
      // 注:cxGridDBTableView1VENDOR_ID: TcxGridDBColumn;
      (Sender as TcxExtLookupComboBox).Properties.IncrementalSearch := False; //必需
      (Sender as TcxExtLookupComboBox).Properties.CaseInsensitive := True;    //必需
      //(Sender as TcxExtLookupComboBox).Properties.IncrementalFiltering := False;//设计期在Properties中设置好.
      //(Sender as TcxExtLookupComboBox).Properties.CaseSensitiveSearch := False; //设计期在Properties中设置好.
      //(Sender as TcxExtLookupComboBox).Properties.DropDownListStyle := lsEditList;//设计期在Properties中设置好
      vInputText := (Sender as TcxExtLookupComboBox).EditText;
      // with (cxGrid1DBTableView1VENDOR_ID.Properties as TcxExtLookupComboBoxProperties) do
      with (Sender as TcxExtLookupComboBox).Properties do    // 改为通用写法.
      begin
        View.DataController.Filter.Options := [fcoCaseInsensitive];
        View.DataController.Filter.Clear;
        View.DataController.Filter.Root.Clear;
        // view中所有可视列都用于模糊检索.
        for iCol := 0 to View.VisibleItemCount - 1 do
        begin
          if iCol > 0 then View.DataController.Filter.Root.BoolOperatorKind := fboOR;
          View.DataController.Filter.Root.AddItem(View.VisibleItems[iCol], foLike,
           '%' + vInputText + '%', '%' + vInputText + '%');
        end;
        View.DataController.Filter.Active := True;
      end;
    end;

    3、Properties.OnCloseUp事件代码:
    procedure TFormcxLookupCombox.cxGridDBTableView1VENDOR_IDPropertiesCloseUp(Sender: TObject);
    begin
      (Sender as TcxExtLookupComboBox).Properties.View.DataController.Filter.Clear;

    end;

    如果不是在cxGrid的列中编辑数据,则可以用TcxDBExtLookupComboBox控件实现,方法与上述雷同!

    转自:http://blog.csdn.net/qq56430204/article/details/52199007

     

  • 相关阅读:
    第 1 章 第 11 题 图纸传递问题
    第 1 章 第 10 题 主键查找问题 哈希表实现
    第 1 章 第 9 题 使用未初始化数组问题 设立辅助数组实现
    第 1 章 第 8 题 分批排序问题( 扩展 ) 位向量实现
    第 1 章 第 7 题 位向量中的异常处理问题
    JAVA实现多线程处理批量发送短信、APP推送
    转载的一些面试题
    使用Flexible实现手淘H5页面的终端适配
    2016前端代码总结
    移动前端的一些坑和解决方法(外观表现)
  • 原文地址:https://www.cnblogs.com/stroll/p/5770561.html
Copyright © 2011-2022 走看看