【问题标题】:How to filter a list from sublist如何从子列表中过滤列表
【发布时间】:2013-12-06 17:47:19
【问题描述】:

我有一个与数据源绑定的列表框。我已将此列表框的所有项目保存在通用类型列表中,如下代码。

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

我已经为列表框的多扩展选择做了一些鼠标点击代码。这些选定的项目与另一个列表的类型相同,如下所示。

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

现在我有一个复选框,当我选中复选框时,它只返回那些不在reportRow 列表中的项目,并且我取消选中它返回完整列表为lstreprot 的复选框。那么如何过滤来自lstreport 的项目?

【问题讨论】:

  • 不清楚你在问什么。您想从lstreport 列表中获取选定的项目吗?
  • NO..我想过滤不包含“reportRow”列表的“lstreport”列表。

标签: c# checkbox listbox


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    • 2018-10-10
    • 2021-08-18
    • 1970-01-01
    相关资源
    最近更新 更多