Board index » delphi » Adding lines to TMemo / RichEdit

Adding lines to TMemo / RichEdit

'lo people,

This one had me going for a while and i couldnt figure it out.
How do add text to Memo or RichEdit? the answer is ez.
Memo1.Lines.Add(DBRichEdit1.Text), and now the text in DBRichEdit, is added
to Memo1, but the trouble is: it gives a hard-return, and then adds the
text. So if Memo1 had sumtin like this in it's lines.strings:

"Dear "

This is what would be the case after i've added sumtin from DBRichEdit (or
nething else)

"Dear
Danny"

In case you didnt notice yet. I don't want this. I want it to be like this:

"Dear Danny"

But how do i do this???
Ne help will be grately appreciated.

Stefan Melis

 

Re:Adding lines to TMemo / RichEdit


Take a look at the properties SelStart and SelText.

Timo

Stefan/GertJan <StefanMe...@yahoo.com> schreef in berichtnieuws
7t8dd5$h0...@reader1.wxs.nl...

Quote
> 'lo people,

> This one had me going for a while and i couldnt figure it out.
> How do add text to Memo or RichEdit? the answer is ez.
> Memo1.Lines.Add(DBRichEdit1.Text), and now the text in DBRichEdit, is
added
> to Memo1, but the trouble is: it gives a hard-return, and then adds the
> text. So if Memo1 had sumtin like this in it's lines.strings:

> "Dear "

> This is what would be the case after i've added sumtin from DBRichEdit (or
> nething else)

> "Dear
> Danny"

> In case you didnt notice yet. I don't want this. I want it to be like
this:

> "Dear Danny"

> But how do i do this???
> Ne help will be grately appreciated.

> Stefan Melis

Re:Adding lines to TMemo / RichEdit


Quote
> This is what would be the case after i've added sumtin from DBRichEdit (or
> nething else)

> "Dear
> Danny"

> In case you didnt notice yet. I don't want this. I want it to be like
this:

> "Dear Danny"

> But how do i do this???
> Ne help will be grately appreciated.

memo.lines[X]:=memo.lines[X]+' Danny';

/Morten

Re:Adding lines to TMemo / RichEdit


In article <7t8dd5$h0...@reader1.wxs.nl>, "Stefan/GertJan"

Quote
<StefanMe...@yahoo.com> writes:
>How do add text to Memo or RichEdit? the answer is ez.
>Memo1.Lines.Add(DBRichEdit1.Text), and now the text in DBRichEdit, is added
>to Memo1, but the trouble is: it gives a hard-return, and then adds the
>text. So if Memo1 had sumtin like this in it's lines.strings:

>"Dear "

>This is what would be the case after i've added sumtin from DBRichEdit (or
>nething else)

>"Dear
>Danny"

>In case you didnt notice yet. I don't want this. I want it to be like this:

>"Dear Danny

Just concatenate the Text of the two controls after deleting the last two
characters (CR and LF) of  Memo1.Text :-

  with Memo1 do
    Text := Copy(Text, 1, Length(Text) - 2) + ' ' + RichEdit1.Text;

Alan Lloyd
aangll...@aol.com

Re:Adding lines to TMemo / RichEdit


Quote
> This is what would be the case after i've added sumtin from DBRichEdit (or
> nething else)

> "Dear
> Danny"

> In case you didnt notice yet. I don't want this. I want it to be like
this:

> "Dear Danny"

> But how do i do this???
> Ne help will be grately appreciated.

memo.lines[X]:=memo.lines[X]+' Danny';

/Morten

Other Threads