Autor Beitrag
Kri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 118



BeitragVerfasst: Sa 12.04.08 00:07 
Hallo zusammen,

ich sitze vor folgendem Problem: Verschiedene Profile sollen in einer Ini gespeichert, bzw. geladen werden (in eine ListBox).

Für das Speichern in der Ini habe ich folgenden Code, der auch funktioniert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
    s:string;
    ini: TIniFile;
begin
  ini:=TIniFile.Create('config.ini');
  try
    for i:=0 to ListBox1.Items.Count-1 do
    begin
    s:='Profil'+IntToStr(i+1);
    ini.WriteString('Profile',s,ListBox1.Items[i]);
    end;
  finally
    ini.free;
  end;
end;


Nun steht in der config.ini z.B.:
[Profile]
Profil1=a
Profil2=b
Profil3=c

Jetzt kommt das eigentliche Problem:

Wie kann ich es machen, dass die Ini in die ListBox kommt, praktisch die umgekehrte Richtung?

So etwas in der Art
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
for i:=1 to //letze Zeile
begin
 a:=ini.ReadString('Profile',Profil[i],'non');
 ListBox1.Items.Add(a);
end;


Viele liebe Grüße
Kri
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Sa 12.04.08 00:46 
ausblenden Delphi-Quelltext
1:
Ini.ReadSection('Profile', Listbox1.Items);					


Edit: Hm ne, damit bekommt man ja nur die Namen, und nicht die Werte.
Dann speicher dir dies in einer StringList zwischen, und mach dann ein ReadString für jeden der Einträge.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 12.04.08 07:07 
Noch einmal der Link, du solltest dir deine Threads auch durchlesen. :wink:
www.kuknet.de/tutorial1.pdf

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Kri Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 118



BeitragVerfasst: Sa 12.04.08 10:38 
Hi,

ok ich merke einmal wieder, dass ich Dinge überlese, habe die Blätter gerade wieder aus dem Müll gefischt, hatte sie mir gleich ausgedrückt.

Ich danke dir vielmals für deine Antwort!

Viele liebe Grüße
Kri