procedure GotoRowCol(Row, Col : Integer; RichEdit : TRichEdit); var TextLen, i : Integer; begin if Row > RichEdit.Lines.Count then Exit; TextLen := 0; for i := 0 to Row - 1 do TextLen := TextLen + Length(RichEdit.Lines[i]) + 1; if (Col <= Length(RichEdit.Lines[Row - 1])) and (Col > 0) then TextLen := TextLen + Col - 1; RichEdit.SelStart := TextLen - Length(RichEdit.Lines[Row - 1]); SendMessage(RichEdit.Handle, EM_SCROLLCARET, 0,0); end;
procedure TForm1.BitBtn1Click(Sender: TObject); begin GotoRowCol(2, 0, RichEdit1);//转到2行0第一个字符处 RichEdit1.SetFocus; end;
|
请发表评论