[英]delphi cxgrid restrict characters
我们正在与devexpress一起在Delphi 2006中工作。
我们有一个cxGrid。 我们要限制数字列的值输入,0到999之间的整数。如果将属性类型设置为SpinEdit,则初始值始终为0,这是不需要的。
因此,我将列的属性值留为null并将列的数据绑定上的数据类型设置为Smallint。 在大多数情况下,这是有效的,但'e'和'。 和“ +”和“-”仍可以输入到导致异常的列中。
是排除“ e”和“。”的一些简单方法。 和“ +”和“-”是否被输入到该列?
可以通过将UseNullString
设置为true来防止初始0值。
不需要的字符的输入可以通过
procedure TForm1.ViewEditKeyPress(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem;
AEdit: TcxCustomEdit; var Key: Char);
begin
if AItem = TheColumnWithSpinEdit then
if (not (Key in ['0'..'9',#8])) then Key := #0;
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.