【发布时间】:2014-06-06 14:15:48
【问题描述】:
我想获取 DataGridViewRow 的索引,其中第一列的值匹配。
到目前为止我的代码:
string SearchForThis = "test";
int index = from r in dgv.Rows
where r.Cells[0].Value == SearchForThis
select r.Index;
编译器错误:
找不到源类型“System.Windows.Forms.DataGridViewRowCollection”的查询模式的实现。 '哪里' 没有找到。考虑明确指定范围变量“r”的类型。
【问题讨论】:
-
尝试将
dgv.Rows替换为dgv.Rows.Array。这行得通吗?
标签: c# linq datagridview