I’ve googled and checked many places for a solution, but all cases I found differed or involved something more advanced than simply adding or deleting lines. Basically, I want to make a sort of scrolling rich edit (alternative would be moving the caret to the bottom, which I already found a solution for).
I’m adding lines to it and checking Lines.Count with the OnChange event of the rich edit and as soon as it reaches value greater 15 I want to call Lines.Delete(0), however I get the error:
RichEdit line insertion error
Can someone tell me what am I doing wrong here ?
You are getting the
RichEdit line insertion errorbecause of check added to the Delphi 2009 version. This check verifies if the insertion of a new line has been successful and this check uses for it the selection position. Unfortunately, for the following piece of code:The workflow looks like this:
Also, before someone fix this issue, don’t use even this, it will cause the same error:
If you didn’t fell asleep from this boring story, then I can suggest you just to avoid the manipulation with the lines in OnChange event as much as you can (better to say, only when you know what can happen).