Einzelnen Beitrag anzeigen

capo

Registriert seit: 7. Jul 2006
453 Beiträge
 
Delphi 11 Alexandria
 
#7

Re: In 2 Stringgrids Reihen vergleichen

  Alt 31. Jan 2007, 10:25
So suche ich im ersten Stringgrid

Delphi-Quellcode:
procedure ClearGrid(sg: TSTringGrid);
var
  iCol: Integer;
begin
  with sg do
  begin
    RowCount := Succ(FixedRows);
    for iCol := FixedCols to Pred(ColCount) do
      Cells[iCol, FixedRows] := '';
    Tag := 0; // internal rowcount
  end;
end;

procedure AppendRow(sg: TStringGrid; s: TStrings);
begin
  with sg do
  begin
    if Tag > 0 then
      RowCount := RowCount + 1;
    Rows[Pred(RowCount)].Assign(s);
    Tag := Succ(Tag); // internal rowcount
   // if RowCount=0 then exit
  end;
end;

procedure CopyRowsContaining(sg, sgResult: TStringGrid; search: string);
var
  i: Integer;
begin
  ClearGrid(sgResult);
  with sg do
    for i := FixedRows to Pred(RowCount) do
      if AnsiContainsText(Rows[i].Text, search) then
        AppendRow(sgResult, Rows[i]);
end;
Delphi-Quellcode:
var
  s: string;
begin
  s := '';
  s := findtext.Text;
  if s <> 'then begin
    CopyRowsContaining(StringGrid1, StringGrid2, s);
Hotte
  Mit Zitat antworten Zitat