Board index » cppbuilder » Loading text into richedit from a TStringList using Add()..

Loading text into richedit from a TStringList using Add()..


2006-03-07 12:14:11 AM
cppbuilder91
I have a function that accepts two AnsiStrings as paramters. In the
function I use a TRichEdit->Add() method to add the text from the
AnsiStrings to the rich edit. The problem is that at one point I want to
add all the lines from a TStringList to my function. I have been using
the ->Text property but that results in all the lines in the
TStringLists be inserted on teh same line of the RichEdit rather than
under each other. Is there an easy way to sort this or do I need to pass
the entire TStringList, access and Add() each line separately? I know
their are several ways of doing it, I'm just curious to see which is the
best and most efficient way. Cheers,
Rory.
 
 

Re:Loading text into richedit from a TStringList using Add()..

"Rory Walsh" < XXXX@XXXXX.COM >wrote in message
Quote
I have a function that accepts two AnsiStrings as paramters. In the function
I use a TRichEdit->Add() method to add the text from the AnsiStrings to the
rich edit. The problem is that at one point I want to add all the lines from
a TStringList to my function. I have been using the ->Text property but that
results in all the lines in the TStringLists be inserted on teh same line of
the RichEdit rather than under each other. Is there an easy way to sort this
or do I need to pass the entire TStringList, access and Add() each line
separately? I know their are several ways of doing it, I'm just curious to
see which is the best and most efficient way. Cheers,
The most efficient way to add text to a richedit is to use RichEdit1->SelText.
RichEdit1->SelStart=RichEdit1->GetTextLen();
RichEdit1->SelText="Line to add to richedit control\r\n";
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
 

Re:Loading text into richedit from a TStringList using Add()..

Quote
add all the lines from a TStringList to my function. I have been using
the ->Text property but that results in all the lines in the TStringLists
be inserted on teh same line of the RichEdit rather than under each other.
I'm not sure that I understoud the Q, but TRichEdit has
Lines property and AddStrings:
RichEdit1->Lines->AddStrings( YourStringList );
also:
RichEdit1->Lines->Assign( YourStringList );
But this will delete previous entries.
--
Best Regards,
Vladimir Stefanovic
 

{smallsort}

Re:Loading text into richedit from a TStringList using Add()..

Rory Walsh wrote:
Quote
The problem is that at one point I want to add all the lines from a
TStringList to my function.
Try this code:
RichEdit1->SelStart = RichEdit1->GetTextLen();
RichEdit1->SelText = MyStringList->Text;
HTH
Jonathan