开发者

Exception problem when rebinding DataViewGrid

I have a List<> that I bind to a DataViewGrid using a Binding source. Like this:

    private void BindGridView(DataGridView dgv, List<KeyTextPair> list, Func<KeyTextPair, int, bool> predicate)
   {
        BindingSource bs = new BindingSource();
        bs.DataSource = list.Where(predicate);
        dgv.DataSource = bs;
    }

I have a collection of such lists, which the us开发者_如何学Pythoner can chose from to display in the DVG. However, upon attempting to change one list for another by rebinding I get the error:

"Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function."

I've looked around for a couple of hours but i still haven't figured out why this is happening.

I'll be very happy if one of you guys can help me.

Thanks.


In second line you need to convert collection to list:

bs.DataSource = list.Where(predicate).ToList();

p.s. If that doesn't solve your problem please post your predicate code

cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜