Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TRichEdit Control

Status
Not open for further replies.

carriemjohnson

Programmer
Aug 26, 2002
11
0
0
US
Hi,

I have a beginner question...I'm trying to use a TRichEdit control to change an RTF string into a regular string...but I'm not sure what methods to use in Delphi. Can anyone point me in the right direction?
 
When you say that you want to convert a RTF string is this what you mean:-

You can make the assigment.

s := richedit1.Lines.Strings[0];

Where s is a variable of type string;
s will contain only the charater information in the string.

Try cutting and pasting some formattted text (e.g the red text on this page) into your Richedit, then use the line above to copy it into a string Var, then transfer it to an edit box, it will have lost the fomating but retain the text content.



Steve
Those who know me have no need of my name. SD
 
Sorry Steve, but the code above will only take the first line of text from the RichEdit. If your string spans more than one line, you will lose the second part of it.

Instead try
Code:
MyString := RichEdit1.Lines.Text;
This will give you entire text in one string variable but you should remember that normal string variables have a limit on size (255 Characters) so if you expect you text to be quite long, look into using the AnsiString variable.

[blue]A good friend will come and bail you out of jail, but a true friend will be sitting next to you saying "Damn that was fun!"[/blue]
 
Eric is quite right the most efficient way to 'reformat' your text would be to take it as an entire chunk, as he suggests.
Eric more on this in 'Another place'.


Steve
Those who know me have no need of my name. SD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top