在datagridview列中查找字符串

时间:2011-08-15 11:06:53

标签: c# linq lambda anonymous-function

我想使用 LINQ 匿名方法或 lambda表达式在特定列中搜索特定字符串。

1 个答案:

答案 0 :(得分:1)

使用LINQ

以下代码会返回特定列ColumnIndex具有值ValueToFind

的所有行
List<DataGridViewRow> records = (from DataGridViewRow row in dataGridView.Rows
                      where row.Cells[ColumnIndex].Value.ToString().Equals("ValueToFind")
                      select row).ToList();