Re: add line in mixed format

Posted by webmaster Guido on June 07, 2005

In Reply to: Re: set TRichEdit text in bold posted by joe90 on June 05, 2005

: Ahh i see.. Now one more thing. How about if I wanted to add a line with differen't font styles on the same line. For example:

: This is underlined: But this regular.

In this case, we can't use RichEdit.Lines.Add twice, because that would add an end-of-line code each time.
But we can insert text without an end-of-line anywhere in Delphi's RichEdit by using the SelText property, like in this source code example:

RE.SelStart := Length(RE.Text);   // put cursor at end
RE.SelAttributes.Style := [fsUnderline];
RE.SelText := 'This is underlined';
RE.SelStart := Length(RE.Text);   // put cursor at end
RE.SelAttributes.Style := [];
RE.SelText := ', but this is normal';
RE.Lines.Add('');                 // add end-of-line