Вот так сойдёт? Если оно ещё надо
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
F: System.Text;
S : TStringList;
Line: String;
begin
if OpenDialog1.Execute and
FileExists(OpenDialog1.FileName) then
with StringGrid1 do
try
AssignFile(F, OpenDialog1.FileName);
FileMode := 0;
Reset(F);
S := TStringList.Create;
ColCount := 2;
RowCount := 2;
while not EOF(F) do
begin
ReadLn(F, Line);
S.DelimitedText := IntToStr(RowCount-1) + ' ' + Line;
ColCount := Max(ColCount, S.Count);
Rows[RowCount-1] := S;
RowCount := RowCount + 1;
end; // while not EOF(F) do
finally
RowCount := RowCount - 1;
S.Free;
if TTextRec(F).Mode <> fmClosed then
CloseFile(F);
end; // try
end; // procedure TForm1.Button1Click(Sender: TObject)