Forum > RichMemo

TRichMemo - idiot question


I have just started using TRichMemo. I load text into the RTF field, and it gets displayed ok, with line breaks automatically adjusting when the TRichMemo is resized. So far so good.

I thought I would be able to put RTF markup tags within the text and get the text formatted when displayed by the TRichMemo. That doesn't happen, so I must have misunderstood something. How do I get RTF markup to work?

My basic test is to put \par...\pard around some text in the RTF field, but those tags just get displayed as text.

To add "markup" you have to use the several properties that deal with it: paragraph alignment. bullets, bold text, etc. You don't just add the tags to the text and hope they get re-interpreted. See how it's done in the wiki: RichMemo

To do what you want you'd have to open the rtf file as a text file using a plain-text edit control like, say. a TMemo, and use the TRichMemo only to display the result.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  rtf_open = '{\rtf1\ansi ';  rtf_close = '}'; procedure TForm1.Button1Click(Sender: TObject);var  Stream : TMemoryStream;  Source : string;begin  Source := rtf_open + 'Some \par text.' + rtf_close;  Stream := TMemoryStream.Create;  Stream.WriteBuffer(Pointer(Source)^, Length(Source));  Stream.Seek(0,soFromBeginning);  RichMemo1.LoadRichText(Stream);  Stream.Free;end; 


[0] Message Index

Go to full version