Displaying text in a TRichEdit?


Posted by Jeff on February 20, 2001 at 22:07:26:

I need to display one line to a RichEdit with part of line diplaying in Bold font. Here is an example, but it will display on 2 separate lines, but I need to display on one line:

WHAT IS YOUR NAME? JOHN SMITH

Display this on one line with John Smith in Bold font?

procedure TForm1.Button1Click(Sender: Object);
var 
  question, answer : String;
begin
  question := 'What is your name?';
  answer := 'John Smith';

  //Display the question to RichEdit which is set for Regular Font
  RichEdit1.Lines.Add(question);

  //set RichEdit to Bold font
  RichEdit1.SelAttributes.Style := [fsBold];

  //display answer to RichEdit
  RichEdit1.Lines.Add(answer);

  //set RichEdit back to Regular Font
  RichEdit1.SelAttributes.Style := 
    RichEdit1.SelAttributes.Style - [fsBold];
end;

This will actually display the question on one line and the answer on the next line. I need to display both on the same line.

Thanks in advance. Greatly appreciate any assistance.
Thanks again,
Jeff


Related Articles and Replies: