Link to home
Start Free TrialLog in
Avatar of pmarkov
pmarkov

asked on

RichEdit Bold Line

Hello

I want to set run-time some lines in RichEdit to BOLD.

I DON'T WANT to use ADD metod!!!

example:
RichEdit.Lines[5] := Bold; :-)))) What?

Thanks
Avatar of Motaz
Motaz

For example if you want to set the characters from 10 to 15 to be bold you can use this:

RichEdit1.SelStart:= 10;
RichEdit1.SelLength:= 5;
RichEdit1.SelAttributes.Style:= [fsBold];

Motaz
Avatar of pmarkov

ASKER

Yes! But I want select to Bold some Row.

Example: characters from 1 to end-of-row of row(N), where N : Integer;
Avatar of pmarkov

ASKER

Yes! But I want SET to Bold some Row.

Example: characters from 1 to end-of-row of row(N), where N : Integer;

sorry for error :))
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this:

function GetLinePos(Text: string; P: Integer): Integer;
var
  i: Integer;
  Counter: Integer;
begin
  Counter:= 0;
  i:= 0;
  while Counter < P do
  begin
    Inc(i);
    if Text[i] = #13 then
      Inc(Counter);
  end;
  Result:= i;

end;

procedure Select(RichEdit: TRichEdit; StartLine, EndLine: Integer);
var
  StartP, EndP: Integer;
begin
  StartP:= GetLinePos(RichEdit.Text, StartLine);
  EndP:= GetLinePos(RichEdit.Text, EndLine + 1);
  RichEdit.SelStart:= StartP;
  RichEdit.SelLength:= EndP - StartP;
  RichEdit.SelAttributes.Style:= [fsBold];
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Select(RichEdit1, 1, 2); // From 1 to 2
end;

Motaz
if you don't want to lose other styles like underline or italic do

RichEdit1.SelAttributes.Style:= RichEdit1.SelAttributes.Style+[fsBold];

in stead of

RichEdit1.SelAttributes.Style:= [fsBold];
Avatar of pmarkov

ASKER

THANKS for ALL!!! :-))))

I accept kretzschmar  answer because it is this who I need!

But Motaz answer is good too!
I will use it in my next projects :-))
glad to helped you :-)
good luck again

meikl
meikl.. do u still remember about that Rtf>>string>>rtf  ???