Good morning to all,
about TAdvStringGrid search as indicated in the documentation we have this function
function Find(StartCell:TPoint; s:string; FindParams: TFindParams): TPoint;
where StartCell is the starting point.
I have some trouble using this function, the starting point is x,y where x=columns y=rows.
If i need search in column 5 for all rows it's rigth use StartCells(5,-1).
I have some trouble again using
1 fnFindInCurrentRow
2 fnFindInPresetCol
With 2 AdvStringGrid and this procedure
Var R : Integer;
Loc : TPoint;
Fp : TFindParams;
begin
Fp := [fnMatchFull,fnFindInPresetCol];
SG2.FindCol:=5 -1;
for R:=1 to SG1.LastRow do
Begin
Loc:=Point(- 1,-1);
Loc:=SG2.Find(Loc,SG1.Cells[5,R],Fp);
if Loc.Y<>-1 then
Begin
Sleep(5);
End;
End;
end;
i have (assuming searching column is 5 (0,1,2,3,4) where in sg1.cells[5,row] i have the text to search and the columns in both grid are the same) :
1 - fnFindInCurrentCol
No way to match text if in FindParams is declared fnFindInCurrentCol and set sg2.col:=5
The text is found if remove the fnFindInCurrentCol and the starting point is -1,-1.
In this case the returned point is 4,Row.
2 - The above procedure works well if using fnFindInPresetCo i set the real column number (4) and not 5.
The returning point is 4,row
Even if the above procedure works good, is very appreciate a little example on how search text in only one column in the pdf file.
Thank's for attention
Regards
Daniele
If you use the setting fnFindInCurrentCol , this means to search in the column where the focused cell is, and the focused cell can be set with grid.Col / grid.Row properties.
If you use fnFindInPresetCol, then you would set the column to search via property grid.FindCol
So, examples for the two approaches are:
Hi Bruno,
thank's for your reply and sorry for may dalayed reply.
Here your example, very very clear and my error!!
procedure TForm1.Button1Click(Sender: TObject);
begin
advstringgrid1.FindCol := 2;
advstringgrid1.Find(point(2,1),'tofind',[fnFindInPresetCol, fnMatchFull,fnAutoGoto]);
end;
My error is in the point(2,1).
I don't know for any strange reason ... i have alway understood if i declare fnFindInPresetCol (in find option) automatically in the find routine Point.X<>Grid.FindCol it was changed in Point.X:=Grid.FindCol.
Bruno thank's again for your support and sorry for my missunderstood, now all clear.
Regards
Daniele