procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var pos: Cardinal;
begin
with Sender as TEdit do
begin
pos := System.Pos(',', Text);
if not LongBool(Pos) then Dec(Pos);
ReadOnly := not (Key in ['0'..'9', ',', #8]) or
(Pos <> $FFFFFFFF) and (Key = ',') or
((Key <> #8) and (Pos < (SelStart - 1)));
end;
end;