W
W
White_Bambie2019-03-16 10:09:30
Delphi
White_Bambie, 2019-03-16 10:09:30

How to insert text in RichEdit2 after a specified word in RichEdit1?

Good day! Can you please tell me how to add lines in RichEdit2 from RichEdit1 after a certain word in RichEdit1. For
example: RichEdit1 contains the following lines:

First row:
1
2
3
4
5
Second row:
1
2

It is necessary to transfer to RichEdit2 all the lines that come after the "Second Row" after pressing the button.
RichEdit2
1
2

I read about the pos function, but I can't implement the code properly. Do not judge strictly!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-03-16
@White_Bambie

var
  I, Index: Integer;
begin
  Index := RichEdit1.Lines.IndexOf('Второй ряд:');
  for I := Index + 1 to RichEdit1.Lines.Count - 1 do
    RichEdit2.Lines.Add(RichEdit1.Lines[I]);
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question