2

我们正在使用 devexpress 在 Delphi 2006 中工作。

我们有一个 cxGrid。我们想限制数字列的值的输入,0 到 999 之间的整数。如果我将属性类型设置为 SpinEdit,则初始值始终为 0,这是不需要的。

因此,我将列上的属性值保留为 null,并将列的数据绑定上的数据类型设置为 Smallint。这在大多数情况下都有效,但“e”和“。” 并且“+”和“-”仍然可以输入到导致异常的列中。

是一些简单的方法来排除'e'和'.' 和 '+' 和 '-' 被输入列?

4

1 回答 1

0

可以通过设置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;
于 2013-05-15T16:45:28.697 回答