Board index » delphi » Inserting text into TMemo / TRichEdit ?

Inserting text into TMemo / TRichEdit ?

Hi there,

I have this problem. I want to be able to add text into a TMemo
component directly at a specific position, but there isn't any method
which I can find in the help file.

For example this line

        The quick brown

I want to be able to add say 'fox' at the end of brown.
How do i do that ?

Any ideas,suggestions would be greatly appreciated...
THanx in advance,
koos

 

Re:Inserting text into TMemo / TRichEdit ?


Koos,

Set the TMemo's SelStart position to the point where you want to
insert the text. Then set the SelText property to what you want
inserted.

Ken
--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Quote
koos wrote:

> Hi there,

> I have this problem. I want to be able to add text into a TMemo
> component directly at a specific position, but there isn't any method
> which I can find in the help file.

> For example this line

>         The quick brown

> I want to be able to add say 'fox' at the end of brown.
> How do i do that ?

> Any ideas,suggestions would be greatly appreciated...
> THanx in advance,
> koos

Re:Inserting text into TMemo / TRichEdit ?


Koos,

Another option I should have mentioned:

var
   i : Integer;
   s : String;
begin
   s := Memo.Lines[0];
   i := Pos(s, 'brown');
   if i > 0 then begin
      Inc(i, Length('brown') + 1);
      Insert( ' fox', s, i );
      Memo.Lines[0] := s;
   end;
end;

Ken  
--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Quote
koos wrote:

> Hi there,

> I have this problem. I want to be able to add text into a TMemo
> component directly at a specific position, but there isn't any method
> which I can find in the help file.

> For example this line

>         The quick brown

> I want to be able to add say 'fox' at the end of brown.
> How do i do that ?

> Any ideas,suggestions would be greatly appreciated...
> THanx in advance,
> koos

Other Threads