Hola alebritez, bienvenido a los foros de
Club Delphi
Como es costumbre con los iniciados te invitamos a leer nuestra
Guía de estilo.
El ejemplo,
Código Delphi
[-]
...
function CharCount( const ch: Char; const st: string ): Integer;
var
i: Integer;
begin
Result := 0;
for i := 1 to Length( st ) do
if st[i] = ch then Inc( Result );
end;
procedure FileToGridWithFixed( const aFileName: string; Grid: TStringGrid );
var
TS: TStrings;
i : Integer;
begin
TS := TStringList.Create;
try
TS.LoadFromFile( aFileName );
Grid.RowCount := Grid.FixedRows + TS.Count;
Grid.ColCount := Grid.FixedCols + CharCount( ';', TS[0] ) + 1;
for i := 0 to TS.Count-1 do
begin
TS[i] := StringOfChar( ';', Grid.FixedCols ) + TS[i];
Grid.Rows[Grid.FixedRows + i].Delimiter := ';';
Grid.Rows[Grid.FixedRows + i].DelimitedText := TS[i];
end;
finally
TS.Free;
end;
end;
Modo de uso:
Código Delphi
[-]
...
begin
FileToGridWithFixed( 'ARCHIVO.TXT', StringGrid1 );
end;
Saludos