J
A hug. AnsiString and structure containing as many fields as StrinGrid poles, further in each field of structure writing a cell. StringGrid'a and functions sprintf I'm writing the structure in the line, and the line in the file is:Please don't argue if the way doesn't work, eventually you didn't specify exactly how you should write in the file.AnsiString S;
struct SaveStorage(AnsiString One, AnsiString Two, ... ,AnsiString Ten,); //описание структуры для хранения данных таблицы
SaveStorage Storage; //Объявили структуру
FILE *in; //объявляем файл в который сэйвим
in = fopen("TestFile.txt", "wt"); //создаем файл, присваиваем имя
fclose(in);
for(i=0;i<StrinGrid->ColCount; i++) { // в цикле выдергиваем из строки таблицы дынные
Storage.One=StringGrid->Cells[0][i];
Storage.Two=StringGrid->Cells[1][i];
...
Storage.Ten=StringGrid->Cells[9][i];
sprintf (S, "%s %s %s %s %s %s %s %s %s %s \n", // заносим данные из 10 ячеек строки StrinGrid'a в 1 строку (/n - означает перенос в низ на новую строчку в той же строке)
Storage.One,
Storage.Two,
...
Storage.Ten)
in=fopen("TestFile.txt", "at"); //открываем созданный файл
fputs (S, in); // пишем в него строку
fclose(in);
}
Next load from TestFile.txt in StringGridAnsiString One,Two, ... , Ten; //В эти строки будем писать данные из файла (структура для этого не пригодна)
in=fopen("TestFile.txt", "rt");
while(fscanf(in,"%s %s %s %s %s %s %s %s %s %s\n",
&One,
&Two,
...
&Ten)!=EOF) //проще говоря сканим данные пока не наступит конец строки в файле
{
StringGrid1->Cells[0][i]=One; // пишем в строку StringGrid'a отсканенные данные из строки файла
StringGrid1->Cells[1][i]=Two;
...
StringGrid1->Cells[9][i]=Ten;
i++;
}
fclose(in);
The way I checked in person, everything works correctly, unless it's coded in order, otherwise it's possible to give a type--- ♪ money ♪♪P. The S has also tried the way you described, the same headache, I think it's so soft, it's not comfortable.