procedure TF_feiyong.i_yingjiaoKeyPress(Sender: TObject
var Key: Char);
begin
if not (key in ['0'..'9','.',#13,#8]) then
begin
Showmessage('Error');
key:=#0;
end;
end;
继承TEDIT控件后,在onchange里加上一些代码为:
if fgetintonly then
begin
try
if fgetallowminus then //如果允许有正负号
begin
strtoint(trim(text)+'0');//一定要加0,否则当输入负号'-'时会被认为是错误要清空
end
else begin
strtoint(trim(text));
end;
except
text:='';
end;
end;
inherited;