ArtemiyUO Цитата: Может быть кто то делал или есть ссылки какие то?
Был вариант с правкой исходников. Я с ним не работал - нет времени.
Может найдутся желающие попробовать?
[more]
21 Dec 2004
I am programically seaching a grid with incremental search. This is working
fine for strings where the substring is from the start IE looking for abc
and it will find abcdefg (good so far) I have a requirement now to pass the
substring cde and pull the same result (cde is in the middle). I have
tracked the code to a CompareText function
Mark Rohde
21 Dec 2004
Yes, your conclusion is correct, you need to alter some sections that
make use of the CompareText() function. In addition, you will want to
modify the text selection display code used by the incremental search
feature, since it only supports selecting from the first char.
Here are the changes I implemented to have the incremental search
feature fully support searching inside words:
- in cxDataUtils.pas, I added a new global text comparison function:
function PosSubstring(const Str, SubStr: string): integer;
begin
Result := -1;
try
Result := Pos(AnsiUpperCase(SubStr), AnsiUpperCase(Str)) - 1;
except
end;
end;
- then in cxCustomData.pas, function TcxDataControllerSearch.DoSearch, I
made the following change:
commented out this line: if DataCompareText(S, ASubText, True) then
added this line instead: if PosSubstring(S, ASubText) <> -1 then
- then in cxGridCustomTableView.pas, procedure
TcxGridTableDataCellViewInfo.InitTextSelection, I made the following change:
commented out this line: SelStart := 0;
added this line instead: SelStart := PosSubstring(GetText,
Controller.IncSearchingText);
Бrpбd
15 Mar 2005
Hi Бrpбd,
I've adopted and modified your ideas.
1. cxDataUtils ( added )
- function PosSubstring(const Str, SubStr: string): integer;
- added var isDataCompareAnywhere: boolean;
( FALSE: default - search from the 1st position
TRUE: search from anywhere )
- added function DataCompareAnywhere(const S1, S2: string;
ApartialCompare: boolean): boolean;
( avoid conflict between Editor vs GridView
DataCompareText: used by Editor ;
DataCompareAnywhere: used by GridView )
| Here are the changes I implemented to have the incremental search
| feature fully support searching inside words:
| - in cxDataUtils.pas, I added a new global text comparison function:
| function PosSubstring(const Str, SubStr: string): integer;
| begin
| Result := -1;
| try
| Result := Pos(AnsiUpperCase(SubStr), AnsiUpperCase(Str)) - 1;
| except
| end;
| end;
function DataCompareAnywhere(const S1, S2: string; APartialCompare:
Boolean): Boolean;
var
AText1, AText2: string;
L2: Integer;
begin
AText1 := AnsiUpperCase(S1);
AText2 := AnsiUpperCase(S2);
L2 := Length(AText2);
if L2 = 0 then
Result := Length(AText1) = 0
else
if not APartialCompare then
Result := AText1 = AText2
else if not isDataCompareAnywhere then
Result := (Length(AText1) >= L2) and (Copy(AText1, 1, L2) = AText2)
else
Result := ( Pos(AText2, AText1) > 0 ); // new
end;
2. cxCustomData ( modified )
- replaced DataCompareText with DataCompareAnywhere
| - then in cxCustomData.pas, function TcxDataControllerSearch.DoSearch, I
| made the following change:
| commented out this line: if DataCompareText(S, ASubText, True) then
| added this line instead: if PosSubstring(S, ASubText) <> -1 then
3 cxDBData ( added : Support GridMode )
TcxDBDataProvider.DoLocate
- replaced DataCompareText with DataCompareAnywhere
- added DataController.Change([dccSearch]) after
DataController.Change([dccLayout])
( invalidate layout & search )
4. cxGridCustomTableView
| - then in cxGridCustomTableView.pas, procedure
| TcxGridTableDataCellViewInfo.InitTextSelection, I made the following change:
| commented out this line: SelStart := 0;
| added this line instead: SelStart := PosSubstring(GetText,
Controller.IncSearchingText);
|
| Hope this is what you were looking for
|
| --
| Бrpбd
|
Saras Setiawan
[/more]