郁闷了很久总算把TcxDBFilterControl中Like操作的%加上了

//检查用户设定的过滤条件,Like和Not Like操作符的,没加%的,强制在两边加上。这下终于“被人性化”了

userscxDBFilterControl,cxFilterControlUtils,Variants;

type TmyDBFilterControl = class(TcxDBFilterControl) end;

with TmyDBFilterControl(FilterCtrl) do

for i := 0 to RowCount -1 do

if (i>0) and (Rows[i].Condition.&Operator in [fcoLike, fcoNotLike]) then

with Rows[i].Condition do

for j := 0 to Values.Count - 1 do

with Values.Values[j] do begin

if Pos('%', ValueText)=0 then ValueText := '%' + ValueText + '%';

if Pos('%', VarToStr(Value))=0 then Value := '%' + VarToStr(Value) + '%';

end;

你可能感兴趣的:(J#)