문제

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?

도움이 되었습니까?

해결책

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, []);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top