Feature request: implement NumbersOnly property for TCustumEdit
Original Reporter info from Mantis: 452
-
Reporter name: Ihor Lavrynyuk
Original Reporter info from Mantis: 452
- Reporter name: Ihor Lavrynyuk
Description:
add new property to TEdit TDBEdit TLabeledEdit
Sample:
TEdit TDBEdit TLabeledEdit
Property name: DataType: String,Integer,Float,Currency
because it's tired add some check every time:
procedure TFrmMain.KeyVerify(Sender: TObject; var Key: Char);
begin
if Not(Key in ['0' .. '9', ',', '.', ' ', #8]) then
begin
Key := #0;
exit;
end;
if Key in [',', '.', ' '] then
Key := DecimalSeparator;
// if (Key='-') and
// (Pos('-',TEdit(Sender).Text)>0)
// then Key:=#0;
if (Key = DecimalSeparator) and
((TEdit(Sender).Text = '') or (Pos(DecimalSeparator, TEdit(Sender).Text)
<> 0)) then
Key := '.';
end;
some problems can arise with "," or "." with float or currency - for easy resolve add simple property DecimalSeparator->"," or "." and if press "," change to "." and ...