Ver Mensaje Individual
  #8  
Antiguo 03-02-2008
keyboy keyboy is offline
Miembro
 
Registrado: oct 2004
Posts: 367
Reputación: 22
keyboy Va por buen camino
Cita:
Empezado por cHackAll Ver Mensaje
Código Delphi [-]
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;
Curioso código. Creo que podríamos agregar esta condición:

Código Delphi [-]
((Key = ',') and (Length(Text) - SelStart > 2)

Para evitar que alguien escriba 1234, mueva el cursor tres lugares hacia atrás y escriba una coma.

Bye
Responder Con Cita