Delete Line in memo box

Hi Guys,

I have 2 memo boxes side by side.

If I delete a line of text in the left memo I also want the same line in the right memo deleted, how can I do this.

Asw
LVL 1
AswAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

karooCommented:
Asw,

this code will reflect any changes made in Memo1 in Memo2.

procedure TForm1.Memo1Change(Sender: TObject);
begin
  Memo2.Lines.Assign(Memo1.Lines);
end;

does it help you?

Regards
Ben:)
0
karooCommented:
Asw,

this code will remove the exact selected text from the right memo if it is deleted from the left memo:

Memo1 => Left Memo
Memo2 => Right Memo

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
const
  CR = #13;
var
  iLength: Integer;
begin
  if Key = 46 then
  begin
    Memo2.SelStart := Memo1.SelStart;
    iLength := Memo1.SelLength;
    if iLength = 0 then
    begin
      Inc(iLength);
      Memo1.SelLength := Memo1.SelLength +1;
      // check for CR and inc iLength for linefeed also
      if Memo1.SelText = CR then Inc(iLength);
      Memo1.SelLength := Memo1.SelLength -1;
    end;
    Memo2.SelLength := iLength;
    Memo2.ClearSelection;
  end;
end;


if possible you might also want to think about using a ListBox instead of a Memo.

best of luck
Ben:)
0
AswAuthor Commented:
Hi Karoo,

Many thanks for your comment, If you put a few lines as an answer I shall give you the points.

Asw
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

karooCommented:
Asw,

you can also accept an Comment as an answer.

glad to have helped.
Ben:)
0
karooCommented:
doh!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AswAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.