Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2052170
  • 博文数量: 454
  • 博客积分: 10921
  • 博客等级: 上将
  • 技术积分: 5396
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-15 15:20
个人简介

伪IT男

文章分类

全部博文(454)

文章存档

2016年(2)

2013年(6)

2012年(17)

2011年(29)

2010年(24)

2009年(54)

2008年(53)

2007年(202)

2006年(67)

分类:

2011-01-23 00:25:41

我在DataGridView的_CurrentCellChanged或_CellEnter事件中+入了以下代码:

 DataGridViewCell currentCell = this.dgvQuickFilter.CurrentCell;
DataGridViewComboBoxCell dcCell = new DataGridViewComboBoxCell();
..........
..........
this.dgvQuickFilter[e.ColumnIndex, e.RowIndex] = dcCell;//异常的是这一句

常常会报InvalidOperationException,不是每次都会报,信息为:{"操作无效,原因是它导致对 SetCurrentCellAddressCore 函数的可重入调用。"}
我的目的是:将非DataGridViewComboBoxCell 的单元格转为DataGridViewComboBoxCell 单元格;

 
 
错误原因:
this.dgvQuickFilter[e.ColumnIndex, e.RowIndex] = dcCell
会触发_CurrentCellChanged,_CellEnter等事件,从而死循环
解决方法:
改用_SelectionChanged
阅读(1729) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-03-09 13:49:51

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com