Ich habe es jetzt mal so gemacht:
Delphi-Quellcode:
procedure SeekRecords(aFixedRows: integer; aCols: TStrings; aKeys: TStrings;
aSeekList: TList);
var
keyindex: integer;
searchindx: integer;
begin
for keyindex := 0 to Pred(aKeys.Count) do
begin
for searchindx := aFixedRows to Pred(aCols.Count) do
begin
if (aKeys[keyindex] = aCols[searchindx]) then
begin
aSeekList.Add(Pointer(searchindx));
end;
end;
end;
end;
procedure TDemoForm.btn_SeekClick(Sender: TObject);
var
seeklist: TList;
searchkeys: TStringList;
ndx: integer;
begin
searchkeys := TStringList.Create;
seeklist := TList.Create;
try
searchkeys.Add('blubb');
SeekRecords(StringGrid1.FixedRows, StringGrid1.Cols[1], searchkeys, seeklist);
if seeklist.Count = 0 then
begin
ShowMessage('Datensatz nicht gefunden');
end
else
begin
lb_ListBox1.Clear;
for ndx := 0 to Pred(seeklist.Count) do
begin
lb_ListBox1.Items.Add(IntToStr(integer(seeklist.Items[ndx])));
end;
end;
finally
seeklist.Free;
searchkeys.Free;
end;
end;
Stephan B.
"Lasst den Gänsen ihre Füßchen"