改良dbgrideh的文字过滤

uses

   ehlibado;

 

改良dbgrideh的文字过滤,原先过虑需要填%字符串%,修改后,直接填入所要搜索的字符串即可,相关代码:

 

 procedure TSTColumnFilterEh.InternalSetExpressionStr(const Value: String);

  procedure SetLookupKeyValues(var v: Variant);
  var
    i: Integer;
  begin
    if VarIsArray(Expression.Operand1) then
      for i := VarArrayLowBound(Expression.Operand1, 1) to VarArrayHighBound(Expression.Operand1, 1) do
        v[i] := CurrentListDataSet.Lookup(CurrentListField, v[i], CurrentKeyField)
    else
      v := CurrentListDataSet.Lookup(CurrentListField, v, CurrentKeyField)
  end;
var s: string;       // add by cxg
begin
  if Value <> '' then  // add by cxg
    if Pos('%', Value) = 0 then
      s := '%'+value+'%';
  ParseExpression(s);
  FExpressionStr := s;
  if (CurrentKeyField <> '') and (CurrentListDataSet <> nil) and (CurrentListField <> '') then
  begin
    if FExpression.Operator1 <> foNon then
      SetLookupKeyValues(FExpression.Operand1);
    if FExpression.Operator2 <> foNon then
      SetLookupKeyValues(FExpression.Operand2);
  end;
end;
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(grid)