Ver Mensaje Individual
  #2  
Antiguo 16-05-2007
Avatar de BuenaOnda
BuenaOnda BuenaOnda is offline
Miembro
 
Registrado: feb 2006
Ubicación: La Serena - Chile
Posts: 347
Reputación: 21
BuenaOnda Va por buen camino
Talking

Bueno utilizando el codigo que muestras..yo haria lo siguiente..

Código Delphi [-]
 
procedure TForm1.TuGrillaKeyPress(Sender: TObject; var Key: Char);
begin

    //Suponiendo que  "TuGrilla" posee 4 columnas...
      WITH TuGrilla DO
      BEGIN
           CASE Col OF
                1:BEGIN
                       If not (Key in ['0'..'9','.',#8]) then Key:=#0;
                       If (Key='.') and (Pos('.',Cells[Col,Row])>0) Then Key:=#0;
                  END;
                2:BEGIN
                       If not (Key in ['0'..'9','.',#8]) then Key:=#0;
                       If (Key='.') and (Pos('.',Cells[Col,Row])>0) Then Key:=#0;
                  END;
                3:BEGIN
                       If not (Key in ['0'..'9','.',#8]) then Key:=#0;
                       If (Key='.') and (Pos('.',Cells[Col,Row])>0) Then Key:=#0;
                  END;
                4:BEGIN
                       If not (Key in ['0'..'9','.',#8]) then Key:=#0;
                       If (Key='.') and (Pos('.',Cells[Col,Row])>0) Then Key:=#0;
                  END;
           END;
      END;
 
end;

espero que te sirva...
Responder Con Cita