Hello,
Thank you all for taking the time to read my post.
Simple question, what is the best way to split the text of one TMemo into another TMemo.
procedure TForm.ButtonSplit(Sender: TObject);
var
textBefore, textAfter: string;
textCursorPosition: Integer;
begin
textCursorPosition := Memo1.SelStart;
textBefore := Memo1.Lines.Text.Substring(0,textCursorPosition);
textAfter := Memo1.Lines.Text.Substring(textCursorPosition);
Memo1.Text := textBefore;
Memo2.Text := textAfter;
end;
The above code does split the text of Memo1 between itself and Memo2. However, it occurs at some 'random' position before the position of the cursor Memo1.
Is there an offset I am not aware of?
Many thanks!