行不能以编程方式添加到DataGridView的行集合时,该控件是数据绑定 [英] Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound

查看:933
本文介绍了行不能以编程方式添加到DataGridView的行集合时,该控件是数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格,当数据网格中加载;我只是选择一个行,然后按编辑按钮。在编辑新的子打开表单和行的单元格的值传递给子窗体上的控件。但是,当我更改子窗体上的一些价值观和保存他们在网格替换错误来对我说:行不能被编程方式添加到DataGridView的行集合时,该控件是数据绑定即可。这是什么错误的原因和如何克服这一点。

I have a grid and when data is loaded in grid; I simply select a row and press edit button. On edit, new sub form is opened and values of row's cells are passed to controls on sub form. But, when I change some values on sub form and save them to be replaces in grid the error comes to me: Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound. What is cause of this error and how to overcome this.

推荐答案

的原因是行不能以编程方式添加到DataGridView的行集合时,该控件是数据绑定。这是因为结晶水一样清晰​​

The cause is that "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound". It is as clear as crystalline water

解决方案?做的不可以行添加到DataGridView的行集合,将它们添加到底层数据源集合(在您设置到DataGridView的DataSource属性集合)

The solution? Do not add rows to the DataGridView's rows collection, add them to the underlying datasource collection (the collection you are setting in to the DataSource property of the DataGridView)

这篇关于行不能以编程方式添加到DataGridView的行集合时,该控件是数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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