Author: Tomas Rutkauskas How to reposition the cursor in a TEdit Answer: The example below uses two TEdit's: 1 unit Cursor; 2 3 interface 4 5 uses 6 SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, 7 Forms, Dialogs, StdCtrls; 8 9 type 10 TForm1 = class(TForm) 11 Edit1: TEdit; 12 Edit2: TEdit; 13 procedure Edit1Change(Sender: TObject); 14 procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 15 private 16 { Private declarations } 17 public 18 { Public declarations } 19 CurPos: integer; 20 end; 21 22 var 23 Form1: TForm1; 24 25 implementation 26 27 {$R *.DFM} 28 29 procedure TForm1.Edit1Change(Sender: TObject); 30 begin 31 CurPos := Edit1.SelStart; 32 edit2.Text := IntToStr(CurPos); 33 end; 34 35 procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 36 begin 37 if Key = VK_LEFT then 38 dec(CurPos); 39 if Key = VK_RIGHT then 40 inc(CurPos); {Right Arrow} 41 edit2.text := inttostr(CurPos); 42 end; 43 44 end.