Find a row in dataGridView based on column and value

前端 未结 7 1455
轻奢々
轻奢々 2020-12-07 14:54

I have a dataGridView that has 3 columns: SystemId, FirstName, LastName that is bound using database information. I would like to highlight a certain row, which I would do

7条回答
  •  情深已故
    2020-12-07 15:18

    If you just want to check if that item exists:

    IEnumerable rows = grdPdfs.Rows
                .Cast()
                .Where(r => r.Cells["SystemId"].Value.ToString().Equals(searchValue));
    if (rows.Count() == 0) 
    {
        // Not Found
    } 
    else 
    {
        // Found
    }
    

提交回复
热议问题