Solved

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

Posted on 1998-02-27
5
1,002 Views
Last Modified: 2011-04-14
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
Comment
Question by:NikWhit
  • 2
  • 2
5 Comments
 

Expert Comment

by:puppy
ID: 1359883
what you need to do in the project?
0
 
LVL 4

Accepted Solution

by:
itamar earned 20 total points
ID: 1359884
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
 
LVL 1

Author Comment

by:NikWhit
ID: 1359885
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
 
LVL 4

Expert Comment

by:itamar
ID: 1359886
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
 
LVL 1

Author Comment

by:NikWhit
ID: 1359887
Adjusted points to 20
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question