• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

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
0
Asw
Asked:
Asw
  • 4
  • 2
1 Solution
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
karooCommented:
Asw,

you can also accept an Comment as an answer.

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now