richedit.SelStart:=5;
richedit.SelLength:=0;
richedit.SetFocus;

解决方案 »

  1.   

    使用Delphi大本营书中的方法即可,
    row,col为指定的行,列
    procedure SetCaret(RTF: TRichEdit; var row, col: word);
    var
      i,iStopLine,iSelStart:integer;
      Strings:TStrings;
    begin
      if (RTF=nil) then exit;
      Strings:=RTF.Lines;
      if Row=0 then Row:=1;
      if Col=0 then Col:=1;
      //到第Row列,Col行共几个字元
      iStopLine:=Row-1;
      iSelStart:=0;
      for i:=0 to Strings.Count-1 do
      begin
        if i=iStopLine then
        begin
          if Length(Strings[i])>Col then
            Inc(iSelStart,Col)
          else
            Inc(iSelStart,Length(Strings[i])+2);
          Break;
        end;
        Inc(iSelStart,Length(Strings[i])+2);
      end;
      if iSelStart>0 then Dec(iSelStart);
      //以设定标记的方式指定游标位置
      RTF.SelStart :=iSelStart;// + Length(RTF.Lines[i])+2;
      //再次侦测游标位置
      Row:=SendMessage(RTF.Handle,EM_LINEFROMCHAR,RTF.SelStart,0);
      Col:=RTF.SelStart-SendMessage(RTF.Handle,EM_LINEINDEX,Row,0);
      //卷到游标所在位置
      SendMessage(RTF.Handle,EM_SCROLLCARET,0,0);end;
      

  2.   

    要不的,不能够指定到行,我用的是rxrichedit
      

  3.   

    #$^@&@#*^%*$*@^*^(&@*(︿@#$*(&︿
    哎,真是的。自己修改一下就可以了........题目有没有说清楚,把Trichedit改成TRxRichEdit不就行了吗?
    我看你这个样子,别人也没有办法帮你了。
      

  4.   

    不是得的,是在rxrichedit中好像算出来的值不对,不然你试一试
      

  5.   

    要定位,使用RichEdit1.SelStart:=20,定位在第20个字符处
      

  6.   

    中文字应该是两个字符,kingron的方法是可以的,要计算好你指定行前面每行的字符数。
    当然还有更酷的方法,不过好麻烦好麻烦:)