定位richedit的光标

                            move the caret in TRichEdit to a specified position? 
Author: Babak Sateli  
Homepage: http://www.cdcenterco.com 
[ Print tip ]     

Tip Rating (11):   
       



// You can move the caret in a TRichEdit component by using this code :

procedure RichEdit_MoveTo(RichEdit: TRichEdit; LineNumber, CharNumber: Word);
begin
  RichEdit.SelStart := RichEdit.Perform(EM_LINEINDEX, LineNumber, 0) + CharNumber);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RichEdit_MoveTo(RichEdit1,2,5);
  Application.ProcessMessages;
  RichEdit1.SetFocus;
end;

                                

查看回复