绑定源仅添加一次行 [英] bindingsource only add row once
本文介绍了绑定源仅添加一次行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个来自绑定源的数据源的datagridview.
问题是我只能添加一次行,我可以在后台工作程序中以编程方式添加该行.
Hi,
I have a datagridview with a datasource from a bindingsource.
The problem is that i can only add a row once, I add the row programmaticly within a backgroundworker.
mybindingsourc.AddNew();<br />
myDataset.Tables["mytable"].Rows.add();
上面的两个代码行也存在相同的问题.
the two code lines above give the same problem.
推荐答案
如果我了解您的工作,并且想多次将同一行插入到datagridview/bindingsource中,您必须克隆该行并插入克隆.该行是一个对象的实例,因此要获取该对象的单个副本,您必须首先获取一个新实例.
If I understand what you are doing and you want to insert the same row multiple time into the datagridview/bindingsource, you have to clone the row and insert the clone. The row is an instance of an object so to get individual copies of the object you must first get a new instance.
这篇关于绑定源仅添加一次行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文