Set caret position in RichEdit

Posted in Components

Use standard properties of the RichEdit component. SelStart is a new position of the caret. SelLength is the number of characters that are selected. This parameter should be 0, if we want to work with caret only.

procedure TForm1.Button1Click(Sender: TObject);
begin
  with RichEdit1 do
  begin
    SetFocus;
    SelStart:=30;
    SelLength:=0;
  end;
end;