Autor Beitrag
dnk05
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 40


D3 Prof
BeitragVerfasst: Fr 04.03.05 12:33 
Hallo.

Ich will folgendes machen:

Form1 in dem ich Memo1 habe.
Mit einem Klick auf Button1 soll sich Form2 öffenen, wo ein Label ist, in dem der Text aus Memo1 angezeigt werden soll.

Ich habe das bisher so realisiert, dass bei Button1Click Memo1.Text in eine Datei gespeichert wird.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var
  Inhalt: TStringList;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Memo1.Text := '';
  Inhalt := TStringList.Create;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
  inc(i);
  Inhalt.Add (Memo1.Text);
  Inhalt.SaveToFile ('Text'+IntToStr(i)+'.txt');     //damit jeder Text erhalten bleibt und
                                                     // nicht überschrieben wird
  Inhalt.Clear;
end;



Jetzt soll der Text nach Button1Click in Label4 in Form2 erscheinen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
  Inhalt2: TStringList;
  g: Integer;

procedure TForm2.FormCreate(Sender: TObject);
begin
  Inhalt2 := TStringList.Create;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
  inc(g);
  Inhalt2.LoadFromFile ('Text'+IntToStr(g)+'.txt');
  Label4.Caption := Inhalt2;
end;



Doch was sich hier nicht verträgt ist
ausblenden Delphi-Quelltext
1:
  Label4.Caption := Inhalt2;					



Wie mach ich das? Wie forme ich ein StringList zum String um?
und wichtig ist natürlich auch:
Wird der mehrzeilige Text aus Memo1 dann zum einzeiligen Text in Label4?
Oder was gibts noch für einfache Möglichkeiten das darzustellen?


Danke schonmal für eure Hilfe,

dnk05
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 04.03.05 12:43 
ausblenden Delphi-Quelltext
1:
Label4.Caption := Inhalt2.Text;					
dnk05 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 40


D3 Prof
BeitragVerfasst: Fr 04.03.05 12:54 
Hätte nicht gedacht, dass es so einfach ist :)
Danke.

So, habe das Label jetzt aber umgeformt zu einem Edit-Feld, damit alles einzeilig dargestellt wird.

jetzt werden aber bei einem Absatz im Memo-Text zwei schwarze Balken im Edit-Feld angezeigt.
Kann man das irgendwie umgehen, bzw abändern, so dass ich einfach Leerzeichen habe statt den Balken?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 04.03.05 13:02 
Da stehen Zeilenumbrüche.
Nimm StringReplace und ersetze die Zeichen #13 und #10 durch Leerzeichen.

Für Grundlagen-Wissen mit String-Operationen kannst du mal auf meiner Homepage vorbeischauen. Dort gibt es ein Anfänger-Tut mit Source-Beispielen.
dnk05 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 40


D3 Prof
BeitragVerfasst: Fr 04.03.05 13:03 
jasocul hat folgendes geschrieben:
Da stehen Zeilenumbrüche.
Nimm StringReplace und ersetze die Zeichen #13 und #10 durch Leerzeichen.

Für Grundlagen-Wissen mit String-Operationen kannst du mal auf meiner Homepage vorbeischauen. Dort gibt es ein Anfänger-Tut mit Source-Beispielen.


danke
dnk05 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 40


D3 Prof
BeitragVerfasst: Fr 04.03.05 16:11 
Habe das mal alles ausprobiert was auf deiner Homepage steht.
Leider geht das bei mir nicht, da ich ja Delphi 3 Prof benutze.

Ich google grad nach Alternativen, aber gibts was was schon fertig ist, womit ich diese Balken durch Leerzeichen ersetze?
dnk05 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 40


D3 Prof
BeitragVerfasst: Fr 04.03.05 16:18 
Habe das gefunden:

www.delphi-forum.de/...+Versionen_5709.html


Aber das geht nicht, da der Fehler kommt "Anweisungen sind im Interfaceteil nicht erlaubt"


Was soll ich machen?? :oops:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 04.03.05 17:07 
Du kannst statt StringReplace auch mit den Funktionen/Prozeduren Pos, Delete, Insert das ganze selbst basteln.
dnk05 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 40


D3 Prof
BeitragVerfasst: Fr 04.03.05 17:30 
Danke für die Hilfe,

habs jetzt hingekriegt, irgendwie.... :)