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
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
ASKER
Yes! But I want select to Bold some Row.
Example: characters from 1 to end-of-row of row(N), where N : Integer;
Example: characters from 1 to end-of-row of row(N), where N : Integer;
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 :))
Example: characters from 1 to end-of-row of row(N), where N : Integer;
sorry for error :))
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.Sty le:= [fsBold];
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
Select(RichEdit1, 1, 2); // From 1 to 2
end;
Motaz
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.Sty
end;
procedure TForm1.Button1Click(Sender
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.St yle:= RichEdit1.SelAttributes.St yle+[fsBol d];
in stead of
RichEdit1.SelAttributes.St yle:= [fsBold];
RichEdit1.SelAttributes.St
in stead of
RichEdit1.SelAttributes.St
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 :-))
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
good luck again
meikl
meikl.. do u still remember about that Rtf>>string>>rtf ???
RichEdit1.SelStart:= 10;
RichEdit1.SelLength:= 5;
RichEdit1.SelAttributes.St
Motaz