比如 点击按钮实现某行改变颜色。

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/929/929090.xml?temp=.4465143
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      row, i, cnt: Integer;
    begin
      // 取得当前行号
      row := SendMessage(RichEdit1.Handle, EM_LINEFROMCHAR,
        RichEdit1.SelStart, 0);
      cnt := 0;
      for i := 0 to row-1 do cnt := cnt + Length(RichEdit1.Lines[i])+2;
      RichEdit1.SelStart := cnt;
      RichEdit1.SelLength := Length(RichEdit1.Lines[row]);
      RichEdit1.SelAttributes.Color := clRed;  // 设为红色
    end;
      

  3.   

    同意 sysu(死树) 
    有问题请发信息到我的E-mail:[email protected]
      

  4.   

    uses 
      RichEdit; procedure RE_SetSelBgColor(RichEdit: TRichEdit; AColor: TColor); 
    var 
      Format: CHARFORMAT2; 
    begin 
      FillChar(Format, SizeOf(Format), 0); 
      with Format do 
      begin 
        cbSize := SizeOf(Format); 
        dwMask := CFM_BACKCOLOR; 
        crBackColor := AColor; 
        Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format)); 
      end; 
    end; // Example: Set clYellow background color for the selected text. 
    procedure TForm1.Button1Click(Sender: TObject); 
    begin 
      RE_SetSelBgColor(RichEdit1, clYellow); 
    end;
      

  5.   

    用FatMemo控件吧,可以实现任意字符颜色,还支持特殊字符,是用来网络聊天中表情符的实现的。要的话网上找。我也有,给我短信就给你。
      

  6.   

    To: CDSoftwareWj(95927) 和 goodloop(小志~~) 
    你的程序试过了吗? 我这里试一下, 没去效果.
      

  7.   

    同 Wnyu(西门吹水) 情形一样:
    我这边也没效果。