我希望能够获取DataGridViewRow的索引,当第一列的值匹配时。
编译器错误:
找不到 'System.Windows.Forms.DataGridViewRowCollection' 类型的源类型的查询模式实现。未找到“Where”。请考虑明确指定范围变量“r”的类型。
目前我的代码:
string SearchForThis = "test";
int index = from r in dgv.Rows
where r.Cells[0].Value == SearchForThis
select r.Index;
编译器错误:
找不到 'System.Windows.Forms.DataGridViewRowCollection' 类型的源类型的查询模式实现。未找到“Where”。请考虑明确指定范围变量“r”的类型。
dgv.Rows
替换为dgv.Rows.Array
,看看是否起作用? - Alex Barac