Devexpress 匹配数据成员上的XtraGrid集选择

Devexpress 匹配数据成员上的XtraGrid集选择,devexpress,Devexpress,我们希望基于与XtraGrid的datamember类型相同的列表集合在XtraGrid上设置选择 我们现在的做法是迭代gridview行 private void SetSelectedRowsInternal(IList<StrongType> collecshung) { grdvSomeGrid.ClearSelection(); grdvSomeGrid.BeginSelection(); for (int i = 0

我们希望基于与XtraGrid的datamember类型相同的列表集合在XtraGrid上设置选择

我们现在的做法是迭代gridview行

private void SetSelectedRowsInternal(IList<StrongType> collecshung)
    {
        grdvSomeGrid.ClearSelection();
        grdvSomeGrid.BeginSelection();
        for (int i = 0;i < grdvSomeGrid.RowCount;i++)
        {
            StrongType _strongTyped = ((StrongType)grdvSomeGrid.GetRow(i));
            if (collecshung.Where(x => x.Id == _strongTyped.Id).Count() == 1)
                grdvSomeGrid.SelectRow(i);
        }
        grdvSomeGrid.EndSelection();
    }
private void SetSelectedRowsInternal(ILST collecshang)
{
grdvSomeGrid.ClearSelection();
grdvSomeGrid.BeginSelection();
for(int i=0;ix.Id==\u strongTyped.Id).Count()==1)
grdvSomeGrid。选择行(i);
}
grdvSomeGrid.EndSelection();
}

有更好的方法吗?

这取决于你如何填写表格。。。例如,您可以直接迭代
绑定列表
(使用
LINQ
)。但是,如果您发现它花费的时间超过了需要的时间,那么这应该是因为即使对于少量数据,
LINQ
函数也可能被命中100多万次

我建议您使用字典而不是
LINQ
ed集合