关于Richedit的问题,有没有人帮我修改(100分)

  • 主题发起人 主题发起人 djks
  • 开始时间 开始时间
D

djks

Unregistered / Unconfirmed
GUEST, unregistred user!
当richedit2等于richedit1的字符串(汉字)richedit1相对应的字为红色:
var x,y:integer;
curstring:string;
begin
y:=RichEdit2.Lines.Count-1;
curstring:=RichEdit2.Lines[RichEdit2.Lines.Count-1];
x:=Length(curstring)+1;
RichEdit1.SelStart:=y;
RichEdit1.SelLength:=1;
RichEdit1.SelAttributes.Color:=clRed;
end;
 
你可以这样试一式
var Startpos,Toend,x,y:integer;
curstring:string;
begin
curstring:=RichEdit2.Lines[RichEdit2.Lines.Count-1];;
label1.Caption := curstring;
StartPos := 0;
ToEnd := length(Richedit1.text)-1;
X := Richedit1.FindText(curstring,StartPos,toEnd,[stMatchCase]);
//if x<>-1 then
begin
Richedit1.SetFocus;
Richedit1.selstart := X;
RichEdit1.SelLength := Length(curstring);
RichEdit1.SelAttributes.Color:=clRed;
end;

end;
 
后退
顶部