Autor Beitrag
Delphi7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

Win XP Home Edition
Borland Delphi 7 Studio Enterprise
BeitragVerfasst: Di 06.07.04 13:28 
salammalenkum!

ich benutze ein TLabel, eine TListBox und eine TIniFile(ini datei namens Einträge.ini). ich habe eine ini - datei mit mehreren einträgen.

ini - Datei:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
                [Eintrag1]
                 text=hallo

                [Eintrag2]
                 text=tschüss

                [Eintrag3]
                 text=Good Bye


wenn ich nun in der ListBox den item => Eintrag1 markiere, möchte ich dass das label(Label 1) den text von der ini aus liest, so das 'hallo' als caption von label 1 angezeigt wird.

oder


wenn ich eintrag2 markiere soll Label 1 den text tschüss anzeigen und den text von der ini lesen.

ich habe es bis jetzt mit diesem code versucht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var i : integer;
    ini : TIniFile;
begin
ini:=TIniFile.Create('Einträge.ini');
for i:=0 to (ListBox1.Items.Count -1) do
begin
if ListBox1.Selected[i] then
ini.ReadString('' + ListBox1.Items.Strings[i] + '', 'text', Label1.Caption);
end;
end;


aber es klappt nicht so wie ich es möchte

danke für alle comments!!!

Moderiert von user profile iconKlabautermann: Delphi- & Code-Tags hinzugefügt.
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: Di 06.07.04 13:43 
Hi,

TIniFile.ReadString ist eine Funktion, :wink:

versuch es mal so

ausblenden Delphi-Quelltext
1:
Label1.Caption:=ini.ReadString(ListBox1.Items.Strings[i], 'text', 'DEFAULT');					


Der letzte Wert ist ein Default wert, für den Fall das der Eintrag in der INI nicht gefunden wird.
Delphi7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

Win XP Home Edition
Borland Delphi 7 Studio Enterprise
BeitragVerfasst: Di 06.07.04 14:14 
vielen dank für deine hilfe!

war ja nicht so komplie. wie ich dachte. trotzdem danke man!!!!!