为什么DataBinding在第二次不工作? [英] Why DataBinding doesn't work on second time around?
问题描述
当我更改BindingSource的数据源
The error I got when I change the datasource of BindingSource
数据绑定找不到适合所有绑定的所有绑定行的行时,我得到的错误
"databinding cannot find a row that is suitable for all bindings row that is suitable for all bindings"
this.RemoveAllBindings(); // My work-around for the meantime
bdsOrder.DataSource = _ds.Tables["orders"]; // errors here on second time around(first time is blank datatable, second time is when i open existing record, then it errors), dataset comes from Remoting
bdsOrderDetail.DataSource = _ds.Tables["order_detail"];
bdsPhoto.DataSource = _ds.Tables["order_photo"];
bdnPhoto.BindingSource = bdsPhoto;
我的助手扩展方法解决了令人困惑的数据绑定找不到行...错误。
My Helper extension method work-around on perplexing "databinding cannot find a row..." error.
namespace MycComponentExtension
{
public static class Helper
{
public static void RemoveAllBindings(this Form form)
{
RemoveAllBindings((Control)form);
}
private static void RemoveAllBindings(this Control root)
{
foreach (Control c in root.Controls)
{
if (c.Controls.Count > 0) RemoveAllBindings(c);
root.DataBindings.Clear();
}
}
DataBinding找不到行是什么意思 ..错误,如果可能,我可以消除我的工作吗?
What's the meaning of "DataBinding cannot find a row..." error, if at all possible, can I eliminate my work-around on it?
推荐答案
我看到这个错误当没有DataGridView涉及,但是我的数据源正在从另一个线程(顽皮!)更新,我的绑定格式为FormattingEnabled = false。改变这两个似乎解决了这个问题。
I have seen this error when no DataGridView is involved, but my data source was being updated from another thread (naughty!) and my binding had FormattingEnabled=false. Changing both of these seemed to fix the problem.
这篇关于为什么DataBinding在第二次不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!