Posted by webmaster Guido on June 04, 2005
In Reply to: Bold Text TRichEdit posted by joe90 on June 02, 2005 You can set the properties of the selected text of a RichEdit with the property SelAttributes. You can set color, name of the font, style, and so on. For example, to set the selected text in bold, in addition of the other properties: RichEdit1.SelAttributes.Style := RichEdit1.SelAttributes.Style + [fsBold]; If text is selected, the attributes will be applied to the selected text and to newly inserted text. You can select text and/or set the cursor in several ways: Example code for a RichEdit and two buttons: // Set text to BOLD procedure TForm1.btnBoldClick(Sender: TObject); begin RichEdit1.SelAttributes.Style := RichEdit1.SelAttributes.Style + [fsBold]; // add attribute BOLD RichEdit1.SetFocus; end; // Set text to ITALIC and BLUE procedure TForm1.btnItalBlueClick(Sender: TObject); begin RichEdit1.SelAttributes.Color := clBlue; // set color to BLUE RichEdit1.SelAttributes.Style := RichEdit1.SelAttributes.Style + [fsItalic]; // add attribute ITALIC RichEdit1.SetFocus; end;
Related Articles and Replies
|
|