Forum > LCL
[SOLVED] Unwanted additional line in the end of TRichMemo.
CM630:
I have added a RichMemo to a form. I have entered two lines in RichMemo1.Lines.
But when I run the app there is an empty third line.
Can I get rid of it?
I tried to set RichMemo1.ReadOnly := True, but it does not help, the line is still there.
A sample project is attached.
cdbc:
Hi
Maybe:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{ we don't want that pestering last empty line }RichMemo1.Lines.SkipLastLineBreak:= true;this could work?!?
Regards Benny
dsiders:
https://lazarus-ccr.sourceforge.io/docs/rtl/classes/tstrings.skiplastlinebreak.html
https://lazarus-ccr.sourceforge.io/docs/rtl/classes/tstrings.trailinglinebreak.html
Ten_Mile_Hike:
The other responses are best, but there is always *Untested*
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Memo1.text:=Leftstring(Memo1.text,Length(memo1.text)-1) {or -2 if your line is #13#10}
CM630:
None of these works:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- RichMemo1.Lines.SkipLastLineBreak := True; RichMemo1.Lines.TrailingLineBreak := False; RichMemo1.Lines.Options := RichMemo1.Lines.Options - [soTrailingLineBreak];
I uploaded the snippet with them and attached it.
--- Quote from: Ten_Mile_Hike on December 13, 2024, 09:34:47 pm ---
...
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Memo1.text:=Leftstring(Memo1.text,Length(memo1.text)-1) {or -2 if your line is #13#10}
...
--- End quote ---
The last #13#10 is not in the text, but it is displayed, this is the problem. Memo1.text:='1'#13#10'2'; still shows an empty third line.
EDIT: I tried again on another PC (still not sure what is different). Memo1.text:='1'#13#10'2'; does not show an empty line in the end.
Also I found this https://forum.lazarus.freepascal.org/index.php/topic,28818.15.html, because the issue also occurs in TMemo.
Maybe I will use TKMemo, it does not have this issue.
Navigation
[0] Message Index
[#] Next page