Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

2 Simple Memo Quoestions

Hi,

How could I place the cursor in the middle after I insert the text ? Let`s say I insert <a></a> and I want the cursor between the tags.

Also if u can tell me how should I do when I press enter in the memo to replace add <br> before the new line ...

Thanks
0
crystyan
Asked:
crystyan
1 Solution
 
2266180Commented:
1) use the SelStart property. you will have to calculate the exact pozition according to your needs (I would guess that <a></a> will not be the only text in the memo ;)

2) use the onkeypress event:
procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
var i:integer;
begin
  if key=#13 then
  begin
    i:=memo1.SelStart;
    memo1.text:=copy(memo1.text,1,i)+'<br>'+copy(memo1.text,i+1,length(memo1.text));
    memo1.SelStart:=i+4;;
  end;
end;

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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