Go Premium for a chance to win a PS4. Enter to Win

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

Memo.Lines.add ... Easy Points...

Hi,
     I need to add text to a memo, but not at the end of
the file. Can anyone tell me how to do this whereby the
text is added at the cursor? I'm sure it's not hard, but
I can't work it out. It's v. important as it's my final
year project! Please Help! Thanks in advance...
0
NikWhit
Asked:
NikWhit
  • 2
  • 2
1 Solution
 
puppyCommented:
what you need to do in the project?
0
 
itamarCommented:
Hi Nik,

this piece of code will insert a text at the cursor position:

  RichEdit1.SelText := 'Text inserted';

Any doubts, place a comment.

IHTH,
Itamar
0
 
NikWhitAuthor Commented:
Itamar,
    That seems to work fine, thanks! Just one other thing :
is it possible to move the cursor to another position? e.g. if
I wanted to insert the text '\chapter{}' and then leave the
cursor between the curly braces, so the user could insert a
name, how would I do that?
    Thanks... Nik.

0
 
itamarCommented:
Humm, another question and still 10 points ??? P(

Ok, in this specific case do this:

      with RichEdit1 do begin
            SelText := '\chapter{}';
            SetFocus;
            SelStart := RichEdit1.SelStart - 1;
      end;

As the cursor will be positioned at the end of the inserted text, subtracting 1 makes the cursor skips (backwards) the last curly brace.

Bye,
Itamar

P.S.: I'd be gratefull if you could increase some points before grading the answer !
0
 
NikWhitAuthor Commented:
Adjusted points to 20
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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