【问题标题】:delphi cxgrid restrict charactersdelphi cxgrid 限制字符
【发布时间】:2013-05-15 16:06:16
【问题描述】:

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

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

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

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

【问题讨论】:

  • 好问题,雅克 :)

标签: delphi devexpress tcxgrid


【解决方案1】:

可以通过将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;

【讨论】:

  • 谢谢布米。 UseNullString 属性在我们的 cxgridDBColumn 上不存在,但我在视图上实现了您的 ViewEditKeyPress 代码,尽管 AItem = TheColumnWithSpinEdit 从未验证过,但它就像一个魅力,所以我将其更改为 AItem.Caption = TheColumnWithSpinEdit.Caption。我还尝试将 AItem 转换为 TcxGridDBColumn 无济于事。再次感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-11-04
  • 2018-07-24
  • 1970-01-01
  • 1970-01-01
  • 2017-03-05
  • 1970-01-01
  • 2016-05-29
相关资源
最近更新 更多