用下列代码将‘BC’字体变色了
redt1.SelStart := Pos('BC', redt1.Text) - 1;
redt1.SelLength := 2;
redt1.SelAttributes.Color := clRed;但是将光标放到bc后面然后打字,则打出的字也跟着变色了。怎么样不让后来打出的字跟着变色呢。
好象这种问题连WORD都存在。是不是默认将前一个字的格式取出来格式化了新打的字??
诚求解决办法。
redt1.SelStart := Pos('BC', redt1.Text) - 1;
redt1.SelLength := 2;
redt1.SelAttributes.Color := clRed;但是将光标放到bc后面然后打字,则打出的字也跟着变色了。怎么样不让后来打出的字跟着变色呢。
好象这种问题连WORD都存在。是不是默认将前一个字的格式取出来格式化了新打的字??
诚求解决办法。
把RichEdit1.SelAttributes.Color 属性再改回黑色
procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
RichEdit1.SelAttributes.Color := clBlack;
end;
获取当前光标的位置
再RichEdit1.SelAttributes.Color:=clBlack;
redt1.SelLength := 2;
redt1.SelAttributes.Color := clRed; redt1.SelStart:=richedit1.SelStart+Length('BC');
redt1.SelAttributes.Color := clDefault;