RichEdit的SelStart、Sellength设置问题(100分)

阿权

Unregistered / Unconfirmed
GUEST, unregistred user!
我要修改任意一行内容的颜色、字体,如何设置SelStart、Sellength?
 
我想可以这样:
with richedit1 do
begin
plaintext:=false;
FoundAt := richedit1.FindText(lines[3],0,Length(Text),[]);

if (FoundAt <> 0) then
begin
SelStart := FoundAt;
SelLength := Length(lines[3]);
SelAttributes.Size:=16;
end;
end;
 
要是有两行内容相同,而我要修改第二行怎么办?
 
我上面介绍的不过是一种解决办法,如果想确认修改第几行,
用个循环把之前的各行的长度加起来(+1),从而确定
本行的起始位置也是可以的吧! ^_^
 
Hehe, you can find the Line Feed or Carriage Return chars,
i.e. LF, CR, etc, :)
 
With Richedit do
if SelLength<>0 then
StartPos:=SelStart+SelLength
else StartPos:=0;
ToEnd:=Length(text)-FindStart;
FoundAt := FindText(YourText,StartPos,Toend,[stWholeWord]);
if FoundAt<>-1 then
......
end;
 
因为问题的提出者已经很久未到,就结束答案吧。
cHengyAng &amp; dwwang的答案应该都是可行的,每人一半。

-- by 3h
 
顶部