!function(a,b,c){function d(a,b){var c=String.fromCharCode;l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,a),0,0);var d=k.toDataURL();l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,b),0,0);var e=k.toDataURL();return d===e}function e(a){var b;if(!l||!l.fillText)return!1;switch(l.textBaseline="top",l.font="600 32px Arial",a){case"flag":return!(b=d([55356,56826,55356,56819],[55356,56826,8203,55356,56819]))&&(b=d([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]),!b);case"emoji":return b=d([55357,56424,55356,57342,8205,55358,56605,8205,55357,56424,55356,57340],[55357,56424,55356,57342,8203,55358,56605,8203,55357,56424,55356,57340]),!b}return!1}function f(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var g,h,i,j,k=b.createElement("canvas"),l=k.getContext&&k.getContext("2d");for(j=Array("flag","emoji"),c.supports={everything:!0,everythingExceptFlag:!0},i=0;i

让DevExpress V4 的 LookupComboBox 可以多列查询。

  • 内容
  • 评论
  • 相关

经分析修改以下两个文件即可达到目标
cxCustomData.pas 
修改一

  TcxCustomDataController = class(TPersistent, IUnknown)
  private
    FDisplayIndex: Integer; --添加一个属性
    FActive: Boolean;
    FAfterSummaryFlag: Boolean;
    FBookmarkRecordIndex: Integer;
...
  public
     property DisplayIndex: Integer  read FDisplayIndex write FDisplayIndex; --把属性公布出来

修改二

function TcxCustomDataController.DoIncrementalFilterRecord
  (ARecordIndex: Integer): Boolean;
var
  S: string;
  I: Integer;
begin
  Result := False;
  for I := 0 to Fields.ItemCount - 1 do
  begin
    S := GetInternalDisplayText(ARecordIndex, Fields[I]);
    Result := DataCompareText(S, FIncrementalFilterText, True);
    if Result then
    begin
      FDisplayIndex := I;
      Exit;
    end;
  end;
  // 注释掉原来的代码
  // S := GetInternalDisplayText(ARecordIndex, FIncrementalFilterField);
  // Result := DataCompareText(S, FIncrementalFilterText, True);
end;

cxLookupEdit.pas
修改一

function TcxCustomLookupEditLookupData.Locate(var AText, ATail: string;
  ANext: Boolean): Boolean;
  function SetGridFilter(AItemIndex: Integer; const AText: string): Integer;
  ...
  var
    AItemIndex, ARecordIndex: Integer;
    S: string;
  begin
    Result := False;
    DisableChanging;
    try
      AItemIndex := GetListIndex;
      if (AItemIndex <> -1) and (DataController <> nil) then
      begin
        // TODO: Next
        if FVisible and
          Properties.GetIncrementalFiltering 
          { and (Properties.DropDownListStyle <> lsFixedList) }
        then
          ARecordIndex := SetGridFilter(AItemIndex, AText)
        else
          ARecordIndex := Properties.FindByText(AItemIndex, AText, True);
        if ARecordIndex <> -1 then
        begin
          DataController.ChangeFocusedRecordIndex(ARecordIndex);
          DoSetCurrentKey(ARecordIndex);
          Result := True;
          // 此处为添加代码
          if DataController.DisplayIndex > -1 then
          begin
            S := DataController.DisplayTexts[ARecordIndex,
              DataController.DisplayIndex];
            DataController.DisplayIndex := -1;
          end
          else
          begin
            S := DataController.DisplayTexts[ARecordIndex, AItemIndex];
          end;
          // 结束
          AText := Copy(S, 1, Length(AText));
          ATail := Copy(S, Length(AText) + 1, Length(S));
          DoSetKeySelection(True);
        end
        else
          DoSetKeySelection(False);
      end;
    finally
      EnableChanging;
    end;
  end;

经过以上修改重新编译就可以了。

评论

2条评论
  1. Gravatar 头像

    老刘 回复

    能实现输入条件,自动下拉码?而且还是模糊查询

  2. Gravatar 头像

    Aly Chiman 回复

    Hello there,

    My name is Aly and I would like to know if you would have any interest to have your website here at 2lin.net promoted as a resource on our blog alychidesign.com ?

    We are in the midst of updating our broken link resources to include current and up to date resources for our readers. Our resource links are manually approved allowing us to mark a link as a do-follow link as well
    .
    If you may be interested please in being included as a resource on our blog, please let me know.

    Thanks,
    Aly

发表评论

电子邮件地址不会被公开。 必填项已用*标注