При сохранении всё норм а вот при загрузке информация на месте а строк мало как быть?
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
| //---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <fstream.h>
#include <float.h>
#include <cstring.h>
#include <memory>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::bClearClick(TObject *Sender)
{// Очистить
for(int i=0;i<StringGrid1->RowCount;i++)
{
StringGrid1->Rows[i]->Clear();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
StringGrid1->Cells[0][0]="Фамилия";
StringGrid1->Cells[1][0]="Имя";
StringGrid1->Cells[2][0]="Сотовый-1";
StringGrid1->Cells[3][0]="Сотовый-2";
StringGrid1->Cells[4][0]="Домашний";
StringGrid1->Cells[5][0]="ICQ";
StringGrid1->Cells[6][0]="Mail";
StringGrid1->Options<<goEditing;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->StringGrid1->RowCount++;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Form1->Label2->Caption=Form1->StringGrid1->RowCount-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N6Click(TObject *Sender)
{
Form1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N4Click(TObject *Sender)
{
std::auto_ptr<TStringList> SL(new TStringList);
SL->LoadFromFile("1.txt");
for(int i=0;i<SL->Count;i++)
{
StringGrid1->Rows[i]->Delimiter=L';';
StringGrid1->Rows[i]->DelimitedText= SL->Strings[i];
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N3Click(TObject *Sender)
{
// Сохранить
std::auto_ptr<TStringList> SL(new TStringList);
for(int i=0;i<StringGrid1->RowCount;i++)
{
StringGrid1->Rows[i]->Delimiter=L';'; // Разделитель
SL->Add(StringGrid1->Rows[i]->DelimitedText);
}
SL->SaveToFile("1.txt");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int i;
bool found = false;
std::auto_ptr<TStringList>FIND_LIST(new TStringList());
for(i = 0; i < StringGrid1->RowCount; i++)
{
if(StringGrid1->Cells[2][i].UpperCase() == Edit1->Text.UpperCase())
{
FIND_LIST->Add(StringGrid1->Cells[2][i]);
found = True;
}
}
if(found)
{
for(i = 0; i < StringGrid1->RowCount; i++)
{
StringGrid1->Rows[i]->Clear();
StringGrid1->RowCount++;
}
for(i = 0; i < FIND_LIST->Count; i++)
{
StringGrid1->Cells[2][i] = FIND_LIST->Strings[i];
}
}
}
//--------------------------------------------------------------------------- |
|
Добавлено через 11 часов 14 минут
а в ответ тишина)