Autor Beitrag
Sauger Chris
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Sa 08.05.04 21:00 
Hallo
Ich brauche einen Quellcode
der mir zu einem ausgewählten Item einen text in eine memo komp.
ladet.

so wie das Item heiß so soll auch die Datei heißen

Danke

Gruß

Sauger Chris (Delphi7)
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Sa 08.05.04 21:14 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
if listbox1.itemindex >= 0 then
  begin
     memo1.lines.add(listbox1.items[listbox1.itemindex]);
   end
      else
        begin
          showmessage('z.B. kein Eintrag ausgewählt');
        end;
    end;

Das addet den momentan markierten Listboxeintrag in memo1.


Und für den weiteren Teil wäre ganz sinnvoll wenn du dir 5 Minuten Zeit genommen hättest, um den Text so zu formulieren das man auch was versteht...:(

Warum Datei?? Willst du das Memo dann noch als Datei abspeichern oder was?!
Wenn ja:

ausblenden Delphi-Quelltext
1:
memo1.lines.savetofile('c:\kalle\' + listbox1.items[listbox1.itemindex]);					
Sauger Chris Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Sa 08.05.04 21:33 
Titel: Listbox1.itm := Text laden
Ja sorry :oops: hier besser

allso ich will das z.b
1 item soll hallo.txt laden
2 item soll hallo2.txt laden
3-999 usw.

die datei (Text-Datei) heißt genau wie das item
wie kann ich das machen

Danke

Gruß
Sauger Chris(Delphi7)
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Sa 08.05.04 21:46 
Hi,

folgender Code sollte Dir die Datei mit dem Namen, der in der Listbox angewählt ist, in Dein Memo laden.
Habe es nicht probiert, sollte aber gehen.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ListBox1Click(Sender: TObject);
begin
  if ListBox1.ItemIndex > 0
   then Memo1.Lines.LoadFromFile(ListBox1.Items[ListBox1.ItemIndex])
   else ShowMessage('Nichts ausgewählt');
end;


Gruß, jjturbo

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Sauger Chris Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Sa 08.05.04 21:55 
Titel: listbox1.item := Datei
:D Jo :D

Danke

Gruß

Sauger Chris(Delphi7)
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: So 09.05.04 01:29 
Moment noch! Es muss >= 0 heissen! Denn der erste Eintrag in der Listbox ist Eintrag 0.