StringGrid com txt

Delphi

03/02/2004

Bom dia a todos!

Pessoal, estou com dificuldade de utilizar a stringgrid.
Preciso fazer uma tabela de escala de professores, contendo as turmas e os dias da semana (segunda, terça...), quero fazer com que esta escala seja salva em um arquivo texto e quando for preciso ela seja carregada do mesmo arquivo. Tem como

Valeu

Angelo


Angelo

Angelo

Curtidas 0

Respostas

Fabio.hc

Fabio.hc

03/02/2004

Tente assim:

Ex:

- Vc coloca um stringgrid e 3 buttons .

var
  Form1: TForm1;
  arq: TextFile;
  linha: String;
  i, j:integer;

implementation

{$R *.dfm}

procedure TForm1.BtnLerClick(Sender: TObject);
begin
   AssignFile ( arq, ´C:\arqtexto.txt´ );
   Reset ( arq );
   ReadLn ( arq, linha );
   StringGrid1.ColCount:=StrToInt(linha);
   ReadLn ( arq, linha );
   StringGrid1.RowCount:=StrToInt(linha);
   ReadLn ( arq, linha );
   for i:=0 to StringGrid1.RowCount do
      for j:=0 to StringGrid1.ColCount do
         begin
         StringGrid1.Cells[j,i]:=linha;
         ReadLn ( arq, linha );
         end;
   CloseFile ( arq );
end;

procedure TForm1.BtnGravarClick(Sender: TObject);
begin
   AssignFile ( arq, ´C:\arqtexto.txt´ );
   Rewrite ( arq );
   Write ( arq, inttostr(StringGrid1.ColCount ));
   WriteLn ( arq );
   Write ( arq, inttostr(StringGrid1.RowCount ));
   WriteLn ( arq );
   for i:=0 to StringGrid1.RowCount do
      for j:=0 to StringGrid1.ColCount do
         begin
         Write ( arq, StringGrid1.Cells[j,i]);
         WriteLn ( arq );
         end;
   CloseFile ( arq );
end;

procedure TForm1.BtnApagarClick(Sender: TObject);
begin
   for i:=0 to StringGrid1.RowCount do
      for j:=0 to StringGrid1.ColCount do
         StringGrid1.Cells[j,i]:=´´;
end;



GOSTEI 0
POSTAR