Filter BindingSource when DataSource is a BindingList

后端 未结 2 1129
逝去的感伤
逝去的感伤 2020-12-19 20:00

I have read from a excel sheet and wrote this for a BindingList, in Form_Load this is set to a DataSource as BindingSource:

bd = new BindingSource(); //insta         


        
2条回答
  •  庸人自扰
    2020-12-19 20:42

    You can not use Filter property to filter a BindingSource which it's DataSource is set to a BindingList.

    Only underlying lists that implement the IBindingListView interface support filtering.

    You can filter the BindingList using Linq:

    var filteredBindingList= new BindingList(bindingList.Where(x=>some criteria).ToList());
    

    Then you can use filtered binding list as data source.

提交回复
热议问题