Saving data from a StringGrid to a text file like this.

FILE *fop=fopen(SaveDialog1->FileName.c_str(),"wt"); if(fop) { if(nt->RowCount>0) fprintf(fop,nt->Rows[0]->CommaText.c_str()); for(int i=1;i<nt->RowCount;i++) fprintf(fop,"\n%s",nt->Rows[i]->CommaText.c_str()); fclose(fop); } 

nt is a StringGrid How to read from a file using OpenDialog?

    1 answer 1

    I would read not CommaText, but according to Cells [i] [j], then the reverse reading from the file in StringGrid will be facilitated. Read from the OpenDialog-> FileName.c_str () file with:

     while(fscanf(fop, "%s", str) != EOF) { nt->Cells[i][j] = (AnsiString)str; ... }