【发布时间】:2013-03-27 03:48:36
【问题描述】:
我有 StringGrid 并且只想在其中包含单元格 1 或 0。我尝试使用 StringGridGetEditMask
procedure TForm1.StringGrid1GetEditMask(Sender: TObject; ACol,
ARow: Integer; var Value: String);
begin
Value := '0';
if not (strToInt(Value) in [0,1]) then value := #0;
end;
但是我可以输入从 0 到 9 的所有数字。如何过滤除 0 和 1 之外的所有数字?
【问题讨论】:
-
我没有收到您的代码。如果将值
'0'分配给Value,那么StrToInt(Value)肯定等于0? -
我将 value 转换为整数并与 0 和 1 进行比较。如果 value 不是 0 或不是 1,则 value 将等于空字符。