S
2005-03-13 13:48:47 UTC
I'm a Delphi newbie, so please bear with me!
I am trying to insert lines into a memo, wherever the cursor may be. That's
fine if what I'm trying to add in is only one line, but if it's more than
one line, I can't figure out how to do this.
To add one line, I do this:
Memo.Lines[Memo.CaretPos.Y] := 'Blah Blah Blah';
To add more than one line, I have tried inserting the first line using the
code above, then the other lines using:
Memo.Lines.Add('Blah Blah Blah');
But, then these lines go to the bottom of the memo (obviously).
I thought about incrementing CaretPos.Y after each line of text has been
inserted in the memo, but this is no good because firstly, it doesn't work
if more lines to not exist in the memo, and if they do, it will overwrite
them.
So I hope what I'm trying to do makes sense. So, for example, I want to
insert three lines of text wherever the cursor may be. The first line of
text can be inserted on the line of the cursor. The other two need to be
added on lines below them, but the lines need to be added so it doesn't
overwrite any other text that may already exist in the memo below it.
Many thanks in advance.
I am trying to insert lines into a memo, wherever the cursor may be. That's
fine if what I'm trying to add in is only one line, but if it's more than
one line, I can't figure out how to do this.
To add one line, I do this:
Memo.Lines[Memo.CaretPos.Y] := 'Blah Blah Blah';
To add more than one line, I have tried inserting the first line using the
code above, then the other lines using:
Memo.Lines.Add('Blah Blah Blah');
But, then these lines go to the bottom of the memo (obviously).
I thought about incrementing CaretPos.Y after each line of text has been
inserted in the memo, but this is no good because firstly, it doesn't work
if more lines to not exist in the memo, and if they do, it will overwrite
them.
So I hope what I'm trying to do makes sense. So, for example, I want to
insert three lines of text wherever the cursor may be. The first line of
text can be inserted on the line of the cursor. The other two need to be
added on lines below them, but the lines need to be added so it doesn't
overwrite any other text that may already exist in the memo below it.
Many thanks in advance.