在我的DataGridView为什么我不能编辑值,即使它没有设置为只读? [英] Why can't I edit the values in my DataGridView, even though its not set to ReadOnly?

查看:792
本文介绍了在我的DataGridView为什么我不能编辑值,即使它没有设置为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DataGridView,未设置为只读。没有它的列都设置为只读,并且对象势必未设置为只读。然而,我不能编辑DataGridView的项目?在DataGridView的.DataSource属性设置为一个ReadOnlyCollection还<>,但我可以通过编程改变的元素,只是没有从UI。这是怎么回事?

I have a DataGridView, which is not set to ReadOnly. None of its columns are set to ReadOnly, and the object it is bound to is not set to ReadOnly. Yet, I can't edit the DataGridView items? The .DataSource property of the DataGridView is set to a ReadOnlyCollection<>, but I can programmatically alter the elements, just not from the UI. What's going on?

推荐答案

事实证明,如果你的DataGridView绑定到ReadOnlyCollection还,那么即使你可以通过编程编辑集合中的任何项目,在DataGridView会限制你改变值。我不知道这种行为是故意的,但它的东西要注意。

It turns out that if your DataGridView is bound to a ReadOnlyCollection, then even though you can programatically edit any item in the collection, the DataGridView will restrict you from changing the values. I'm not sure if this behavior is intentional, but its something to watch out for.

这篇关于在我的DataGridView为什么我不能编辑值,即使它没有设置为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆