Autor Beitrag
Insignificant
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Fr 04.01.08 20:11 
Hallo. Ich wollte fragen wie ich die letzte Zeile aus einem Richedit Feld in die Caption eines Labels bekomme?

ausblenden Delphi-Quelltext
1:
Label1.Caption := Editor.Lines.Strings[Editor.Lines.Count];					



So funktioniert es leider nicht :(
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Fr 04.01.08 20:18 
ausblenden Delphi-Quelltext
1:
Label1.Caption := Editor.Lines.Strings[Editor.Lines.Count-1];					


Count gibt die absolute Anzahl der Einträge zurück; mit Lines.Strings greifst du auf das Element-1 zu. Deshalb musst du auch 1 abziehen.


Zuletzt bearbeitet von Yogu am Fr 04.01.08 20:19, insgesamt 1-mal bearbeitet
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: Fr 04.01.08 20:19 
ausblenden Delphi-Quelltext
1:
Label1.Caption := Editor.Lines[Editor.Lines.Count-1];					

?

-1 da die Zeilen bei Index 0 anfangen, d.h. wenn du 3 Zeilen hast, haben diese den Index 0, 1 und 2.

Edit: Verdammt, zu langsam ;)