wpf datagrid.itemssource过滤器

时间:2014-08-14 00:56:12

标签: wpf wpfdatagrid

我在wpf中有一个datagrid,我在其中使用了标记ItemSource =“{Binding CompanyTable}”。但问题是,datagrid从CompanyTable加载每一条记录。我想过滤它并阻止StatusId = 0的每个条目在数据网格中显示,但是如何?

1 个答案:

答案 0 :(得分:0)

使用RowFilter然后将行添加到新数据表中,可能如下所示:

        DataTable newdt = new DataTable();
        DataRow[] dr = CompanyTable.Select("StatusId = 0");
        foreach (DataRow row in dr)
        {
            newdt.Rows.Add(row);
        } 
相关问题