找回密码
 立即注册

QQ登录

只需一步,快速开始

qiuzhilv007

中级会员

34

主题

85

帖子

620

积分

中级会员

积分
620

活字格认证微信认证勋章

qiuzhilv007
中级会员   /  发表于:2015-11-26 15:29  /   查看:5402  /  回复:2
GcDateTimeCell设置了最大最小值,编辑时如输入的超出范围值或者只输入了部分数值,例如4位年只输入了3位时,鼠标点击其他单元格后,GcDataTimeCell如何设置能无视非法的输入,返回输入之前的值?

2 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2015-11-26 18:21:00
沙发
回复 1楼qiuzhilv007的帖子

您的问题我们收到了。
校验后给您反馈。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
Carl
版主   /  发表于:2015-11-27 12:15:00
板凳
如果只是判断值超出范围,可以利用Cell.Validators添加一个RangeValidator来实现。
如果想判断只输入了部分数值,这个需要访问InputMan GcDateTime上的属性精确判断,参考代码如下:

  1.         private object oldValue;
  2.         void gcMultiRow1_CellBeginEdit(object sender, CellBeginEditEventArgs e)
  3.         {
  4.             if (e.Scope == CellScope.Row)
  5.             {
  6.                 this.oldValue = this.gcMultiRow1[e.RowIndex, e.CellIndex].FormattedValue;
  7.             }
  8.         }

  9.         void gcMultiRow1_CellValidating(object sender, CellValidatingEventArgs e)
  10.         {
  11.             GrapeCity.Win.Editors.GcDateTime gcDate = this.gcMultiRow1.EditingControl as GrapeCity.Win.Editors.GcDateTime;
  12.             if (gcDate == null)
  13.             {
  14.                 return;
  15.             }
  16.             if (gcDate.Value.HasValue &&
  17.                 !(gcDate.Value.Value >= new DateTime(2015, 1, 1) &amp;&amp; gcDate.Value.Value <= new DateTime(2015, 12, 31)))
  18.             {
  19.                 if (oldValue is DateTime)
  20.                 {
  21.                     gcDate.Value = (DateTime)oldValue;
  22.                 }
  23.             }
  24.             if (gcDate.InputStatus == GrapeCity.Win.Editors.InputStatus.Part)
  25.             {
  26.                 if (oldValue is DateTime)
  27.                 {
  28.                     gcDate.Value = (DateTime)oldValue;
  29.                 }
  30.             }
  31.         }
复制代码

评分

参与人数 1满意度 +5 收起 理由
qiuzhilv007 + 5 thanks

查看全部评分

愿 Engine 归于沉寂,Timer 停止运动,Message Queue 不再流淌,Data Source 为我掌握
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部