Autor Beitrag
patrick dee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 311

Win 98SE, WinXP
D3,D6
BeitragVerfasst: Mi 12.04.06 12:27 
Hi,

so füge ich Einträge in meine ListBox hinzu :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.WaveHinzuClick(Sender: TObject);
var
eintrag:string;
begin
If Opendialog1.Execute Then
eintrag:=OpenDialog1.FileName;
ListBox1.Items.Add('Audio File :   ' + eintrag);
end;


Funktioniert, nur steht der Eintrag nicht am Ende der List, sondern erst kommt eine Leerzeile und dann der Eintrag. Möchte aber das was ich über den OpenDialog lade am Ende der in der ListBox stehen Einträge angefügt wird.

Danke

Patrick

_________________
Glauben heißt nichts wissen ...
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 12.04.06 13:26 
Mache es erstmal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.WaveHinzuClick(Sender: TObject);
var
eintrag:string;
begin
If Opendialog1.Execute Then
begin
  eintrag:=OpenDialog1.FileName;
  ListBox1.Items.Add('Audio File :   ' + eintrag);
end;
end;


Vielleicht fügst du an einer anderen Stelle einen Eintrag hinzu, der aus Leerzeichen etc. besteht, und du weißt es gar nicht :gruebel:

Kannst du mal den anderen Code zeigen?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
raiguen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 374

WIN 2000prof, WIN XP prof
D7EP, MSSQL, ABSDB
BeitragVerfasst: Mi 12.04.06 13:54 
Moin :-)
user profile iconpatrick dee hat folgendes geschrieben:
Hi,

so füge ich Einträge in meine ListBox hinzu :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.WaveHinzuClick(Sender: TObject);
var
eintrag:string;
begin
If Opendialog1.Execute Then
eintrag:=OpenDialog1.FileName;
ListBox1.Items.Add('Audio File :   ' + eintrag);
end;


Funktioniert, nur steht der Eintrag nicht am Ende der List, sondern erst kommt eine Leerzeile und dann der Eintrag. Möchte aber das was ich über den OpenDialog lade am Ende der in der ListBox stehen Einträge angefügt wird.

Danke

Patrick

Der Fehler liegt in dem Code, genauer gesagt: in Zeile 7. Warum? Nun, wenn Du den OpenDialog abbrichst, dann ist die Variable eintrag leer, also steht in der Listbox auch nur 'Audio File : ' ;-)

Der Vorschlag von user profile iconMarco D. ist also der richtige Weg. Optimierung:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.WaveHinzuClick(Sender: TObject);
begin
If Opendialog1.Execute Then
  ListBox1.Items.Add('Audio File :   ' + OpenDialog1.FileName);
end;