Board index » delphi » Insert text in cursor pos in a Memo or RichEdit

Insert text in cursor pos in a Memo or RichEdit

Hi!
I want to add some specific text in cursor position in a memo or an
richedit, for example I have:

" Date: (cursor here)"

and I want when I click a button it add's the date like this:

" Date: 06/Jun/2001(cursor here)"

How do I add the date like this? Is there any procedure that does that? like
.ADD('06/Jun/2001'); or .APPEND('06/Jun/2001');?
Thanks in advance,

jS

 

Re:Insert text in cursor pos in a Memo or RichEdit


Quote
"Julio Silva" <zeju...@mail.telepac.pt> wrote in message

news:9flb4m$djl$1@venus.telepac.pt...

Quote
> Hi!
> I want to add some specific text in cursor position in a memo or an
> richedit, for example I have:

> " Date: (cursor here)"

> and I want when I click a button it add's the date like this:

> " Date: 06/Jun/2001(cursor here)"

> How do I add the date like this? Is there any procedure that does that?
like
> .ADD('06/Jun/2001'); or .APPEND('06/Jun/2001');?

memo1/richedit1.SelText := '06/Jun/2001';

Re:Insert text in cursor pos in a Memo or RichEdit


Hi

This is fairly simple.  You need to get the cell position of your cursor.

create a variable -
var
  StringData : String
  Temp : Integer;

StringData := '06/Jun/2001';

Temp := Length(StringData);
RichEdit1.SelStart := Length(RichEdit1.Text);
RichEdit1.SelText := StringData;

This will add the data at the flashing cursor

Hope this helps

Regards

Quote
"Julio Silva" <zeju...@mail.telepac.pt> wrote in message

news:9flb4m$djl$1@venus.telepac.pt...
Quote
> Hi!
> I want to add some specific text in cursor position in a memo or an
> richedit, for example I have:

> " Date: (cursor here)"

> and I want when I click a button it add's the date like this:

> " Date: 06/Jun/2001(cursor here)"

> How do I add the date like this? Is there any procedure that does that?
like
> .ADD('06/Jun/2001'); or .APPEND('06/Jun/2001');?
> Thanks in advance,

> jS

Re:Insert text in cursor pos in a Memo or RichEdit


Quote
"Julio Silva" <zeju...@mail.telepac.pt> wrote in message

news:9flb4m$djl$1@venus.telepac.pt...

Quote
> Hi!
> I want to add some specific text in cursor position in a memo or an
> richedit

Read SelText to determine the value of the selected text. Set SelText to
replace the selected text with a new string. If there is no selection, but
the edit control has focus, set SelText to insert a new string into the text
at the cursor. (Form D5 help file).

The following code will insert 123 into RichEdit1's text at the cursor, but
will not overwrite any selected text:

  RichEdit1.SelLength := 0;
  RichEdit1.SelText := '123';

Christo Crause

Other Threads