Reputation: 367
How can I make the first 4 characters in a line I am going to add bold?
Example:
richedit1.Lines.Add('Test123');
I want Test
to be bold but leave 123
normal.
Can someone help me?
Upvotes: 2
Views: 1589
Reputation: 595837
Try something like this:
procedure TForm1.AddFormattedText(const AText: string; AStyle: TFontStyles);
begin
RichEdit1.SelStart := RichEdit1.GetTextLen;
RichEdit1.SelLength := 0;
RichEdit1.SelAttributes.Style := AStyle;
RichEdit1.SelText := AText;
end;
AddFormattedText('Test', [fsBold]);
AddFormattedText('123'+sLineBreak, []);
Upvotes: 2