找回密码
 立即注册

QQ登录

只需一步,快速开始

totem650

新手上路

1

主题

2

帖子

17

积分

新手上路

积分
17
  • 15

    金币

  • 主题

  • 帖子

最新发帖
totem650
新手上路   /  发表于:2014-7-24 14:08  /   查看:5217  /  回复:4
10金币
【问题】CellType设成IntegerCellType后,默认的Validators验证能不能关闭?
【描述】CellType设成IntegerCellType后,Spread就会自动验证输入的合法性。
往Cell里输入字母的话,就会弹出错误信息。但是这时候页面上的提交按钮还是可以点击的,提交后WebServer端取到的值是原来的值,并非刚输入的字母——这是所见非所得啊!

【希望效果】IntegerCellType的默认Validators验证能不能关闭?虽然输入不合法,还是希望能提交到WebServer,因为后台代码是写了合法性验证的。
而不是提交给WebServer原值,原值的话后台代码的合法性验证就没法工作了。

【尝试过的方法】
方法一:无效
  1. dbct.Validators.Remove(dbct.Validators.FirstOrDefault)
复制代码

方法二:无效
  1. dbct.Validators.Add(New CustomValidator())
复制代码


【补充】
版本:SPREAD for ASP.NET 7.0J
代码:(都是因为想自动添加删除逗号,又不想用Javascript惹的祸)

  1. Dim dbct As New FarPoint.Web.Spread.IntegerCellType()

  2.  ' <編集フォーマット>?表示時:999,999
  3. dbct.NumberFormat = New System.Globalization.NumberFormatInfo()

  4.  ' <編集フォーマット>?編集時:999999
  5. dbct.EditMode.NumberFormat = New System.Globalization.NumberFormatInfo()
  6. dbct.EditMode.NumberFormat.NumberGroupSizes = New Integer() {0}

  7. ' セルの型の設定
  8. FpsViaStation.Sheets(0).Cells(0, 1).CellType = dbct

  9. ' セルの値の設定
  10. FpsViaStation.Sheets(0).Cells(0, 1).Value = 12346

复制代码

4 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-7-24 18:09:00
沙发
回复 1楼totem650的帖子

感谢你的详细描述。
仅就描述的这两点问题,使用 GeneralCellType能满足你的需求。
回复 使用道具 举报
totem650
新手上路   /  发表于:2014-7-25 10:22:00
板凳
回复 1楼totem650的帖子

感谢你的详细描述。
仅就描述的这两点问题,使用 GeneralCellType能满足你的需求。
iceman 发表于 2014-7-24 18:09:00


感谢版主百忙之中的回复,是我没描述清楚。
我最想要的效果是:双击进入编辑状态,逗号自动去掉。焦点离开回到表示状态,逗号自动加上。
GeneralCellType好像没有这个功能。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-7-25 18:12:00
地板
回复 3楼totem650的帖子

好的,问题我已经了解了,正在调查中,有进一步结果反馈给你。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-9-23 13:50:00
5#
回复 1楼totem650的帖子

抱歉,让你久等了。请问这个问题解决了吗?
这个问题可以通过设置 GeneralCellType 的 FormatString 来实现:

  1.             FpSpread1.Sheets[0].ColumnCount=7;
  2.             FpSpread1.Sheets[0].PageSize=50;
  3.             FpSpread1.Sheets[0].RowCount=50;
  4.             FarPoint.Web.Spread.GeneralCellType genrl=new FarPoint.Web.Spread.GeneralCellType();
  5.             genrl.FormatString = "###,###";
  6.             FpSpread1.Sheets[0].Columns[0].CellType=genrl;
  7.             FpSpread1.Sheets[0].Cells[0,0].Value=111111;
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部