惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
S
Secure Thoughts
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Troy Hunt's Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
博客园 - 司徒正美
NISL@THU
NISL@THU
小众软件
小众软件
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园_首页
罗磊的独立博客
S
Securelist
N
News | PayPal Newsroom
大猫的无限游戏
大猫的无限游戏
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
爱范儿
爱范儿
Spread Privacy
Spread Privacy
V2EX - 技术
V2EX - 技术
J
Java Code Geeks
V
V2EX
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
I
Intezer
腾讯CDC
P
Privacy & Cybersecurity Law Blog
SecWiki News
SecWiki News
Google DeepMind News
Google DeepMind News
P
Palo Alto Networks Blog
Cloudbric
Cloudbric
Apple Machine Learning Research
Apple Machine Learning Research
N
News and Events Feed by Topic
Latest news
Latest news
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
The Cloudflare Blog

博客园 - 周克

te 关于博客园是否可以开展培训业务的几点思考 - 周克 - 博客园 【收集】Web开发工具 感情 程序 祭 Linq本质论(1) WinForm自动菜单合并 .Net开源控件 Client Settings FAQ .Net学习课件 ClickOnce 部署多语言程序需要注意的地方 WinFX更名为 .NET Framework 3.0. BindingSource.AddingNew事件可以给新增数据设置需要的值 介绍一个可以读取保存在程序集里面的图片资源的小工具 vs2005强类型主从表加上级联约束后无法添加从表数据 MSDN中文资料库WWF链接(updating...) 在WinForm中使用Membership WWF动态加载xoml文件 固定Asp.net2.0 Web项目的动态端口号 深圳.Net俱乐部2.26活动资源下载之——从SmartClient到ClickOnce
可恶的AutoSizeColumnMode和DataError
周克 · 2006-05-29 · via 博客园 - 周克

项目中DataGridView中使用了DataGridViewComboBoxColumn,不记得在哪里看到AutoSizeColumnMode设置成allcells,AutoSizeRowsMode=None,觉得蛮好的,结果把所有表单的DGV都设置成这样,不幸的意外发生了:结果关闭表单的时候就会发生DataError错误,说什么DataGridViewComboBoxCell的值不合法。
这时候还不知道哪里出了问题,以为绑定的顺序有问题,结果无奈之中把所有DGV加了个空的DataError 处理。
后来不甘心,到MSDN论坛上一查,原来碰到这个问题的不止我一个:http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=157106&SiteID=1&PageID=2
下面是DataGridView Program Manager的解答:
 The issue is that the Form's dispose method is first disposing the datasource that the combobox column is using before it is disposing the DataGridview. This is the same as not databinding the combobox column at all. This only causes a problem when autosizing the rows or autosizing the combobox column since removing the combobox column's datasource causes the row/column to perform autosize layout. As part of the layout, the combobo cell needs to retrieve the FormattedValue, which raises the DataError since the cell cannot find a match in the combobox (since the combobox column's datasource is now null).
和处理办法:
The easiest way to fix this is to change the autosize mode of the grid in the form's dispose method. Alternatively you can manually databind the combo box column, including manually creating the BindingSource. This will allow you to manually dispose the combobox column's binding source on your own -- after the grid has already disposed.

未来:
 Currently we do not have any way to specify any dependency for disposing, but in 2005 we did create better support for dependencies when initializing controls/components. Sounds like we need to create some new support to deal with this type of problem.
I've opened a bug to address this issue hoping that we can do something in the next version.
提示: 
以后遇到问题多泡泡MSDN的论坛,比国内的好上一百倍,因为有微软的测试或者设计人员及时解答您的提问。