找回密码
 立即注册

QQ登录

只需一步,快速开始

lqb224

注册会员

2

主题

4

帖子

22

积分

注册会员

积分
22

活字格认证

最新发帖
lqb224
注册会员   /  发表于:2014-7-2 11:36  /   查看:5609  /  回复:4
multirow 7.0J
例:
有这样一行代码:GcMultirow.CurrentCell = GcMultirow.item(0,0)
执行上记代码时,将焦点置到了cell(0,0)上了,并触发cellEnter事件
但在cellEnter事件中,会有类似GcMultirow.CurrentCell = GcMultirow.item(0,1)的代码
再执行这个代码后,会有cell设定失败的异常

请问有什么解决办法?

4 个回复

倒序浏览
dafo
版主   /  发表于:2014-7-2 13:55:00
沙发
不是很清楚你们的业务需求,但是这个逻辑确实造成了GcMultiRow内部的循环错误,建议直接修改代码为设置(0, 1)Cell位置,如果你们是旧代码改造,一个方式是在设置时先摘掉事件,设置完后在代码中强行调用一次事件函数。
回复 使用道具 举报
dafo
版主   /  发表于:2014-7-2 14:11:00
板凳
第二个方案相关代码:

  1.         private void button1_MouseHover(object sender, EventArgs e)
  2.         {
  3.             this.gcMultiRow1.CellEnter -= gcMultiRow1_CellEnter;
  4.             this.gcMultiRow1.CurrentCell = this.gcMultiRow1[0, 0];
  5.             gcMultiRow1_CellEnter(null, null);
  6.             this.gcMultiRow1.CellEnter += gcMultiRow1_CellEnter;

  7.         }

  8.         private void gcMultiRow1_CellEnter(object sender, CellEventArgs e)
  9.         {
  10.                 this.gcMultiRow1.CurrentCell = this.gcMultiRow1[0, 1];
  11.         }
复制代码
回复 使用道具 举报
lqb224
注册会员   /  发表于:2014-7-2 15:40:00
地板
回复 3楼dafo的帖子

多谢回答,上记的意思我懂了,确实是旧代码改造,
但上记的办法在这个项目里无法实现(项目本身原因)
其实上面虽然报错,但最后的结果是正确的
所以有没有可能用什么方法能屏蔽下错误,不让它弹出来?这样结果就正确了
回复 使用道具 举报
dafo
版主   /  发表于:2014-7-2 16:49:00
5#
可以通过捕获异常来处理,代码:
  1.             try
  2.             {
  3.                 this.gcMultiRow1.CurrentCell = this.gcMultiRow1[0, 0];
  4.             }
  5.             catch
  6.             { }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部