简体   繁体   中英

How to filter a list from sublist

I have listbox which is bind with a datasource. I have hold all the items of this listbox in to a generic type list as following code.

List<FRReportRow> lstreport = lstSelectRows.Items.Cast<FRReportRow>().ToList();

I have done some code of mouse click for multiextended selection of listbox. These selected items are in same type of another list as following.

List<FRReportRow> reportRow = 
     lstSelectRows.SelectedItems.Cast<FRReportRow>().ToList();

Now I have a checkbox which returns only those items which are not in the reportRow list when i checked the checkbox and I unchecked the checkbox it returns full list as lstreprot . So How can i filter items from lstreport ?

使用Enumerable.Except获取仅存在于lstreport列表中的行(即未选择的行):

IEnumerable<FRReportRow> notSelectedRows = lstreport.Except(reportRow);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM