Registriert seit: 18. Aug 2004
Ort: Edewecht
712 Beiträge
Delphi 5 Professional
|
Re: In English (Ini question)
27. Dez 2004, 16:48
Zitat von jcop:
I was thinking of porting the button1.openclick event also into the cbosctionschange event but that's resulting in a error.
Delphi-Quellcode:
type
TForm1 = class(TForm)
...
private
{ Private-Deklarationen }
IniFile: TIniFile;
...
end;
...
{------------------------------------------------------------------------------}
procedure TForm1.FormDestroy(Sender: TObject);
begin
if Assigned(IniFile) then
IniFile.Free;
end;
{------------------------------------------------------------------------------}
procedure TForm1.ComboBox1Change(Sender: TObject);
var
Sections: TStringList;
I: Integer;
begin
Sections := TStringList.Create;
try
with Sections, IniFile, ComboBox1 do
begin
ReadSections(Sections);
for I := 0 to Sections.Count - 1 do
if ReadString(Sections[I], 'Title', '') = Items[ItemIndex] then
begin
txtTitle.Caption := ReadString(Sections[I], 'Title', '');
txtColour.Caption := ReadString(Sections[I], 'Colour', '');
txtEngine.Caption := ReadString(Sections[I], 'Engine', '');
txtTurbo.Caption := ReadString(Sections[I], 'Turbo', '');
end;
end;
finally
Sections.Free;
end;
end;
{------------------------------------------------------------------------------}
procedure TForm1.Button1Click(Sender: TObject);
var
Sections: TStringList;
I: Integer;
begin
if OpenDialog1.Execute then
begin
if Assigned(IniFile) then
FreeAndNil(IniFile);
IniFile := TIniFile.Create(OpenDialog1.FileName);
Sections := TStringList.Create;
try
with IniFile, ComboBox1 do
begin
Clear;
ReadSections(Sections);
for I := 0 to Sections.Count - 1 do
if ValueExists(Sections[I], 'Title') then
Items.Add(ReadString(Sections[I], 'Title', ''));
end;
finally
Sections.Free;
end;
end;
end;
{------------------------------------------------------------------------------}
...
Ciao, Sprint.
"I don't know what I am doing, but I am sure I am having fun!"
|
|
Zitat
|