Please, what is wrong here
foreach (DataGridViewRow row in frm02.dgv02.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
if (cell.Value.ToString() == "323")
//if (cell.RowIndex == 3)
{
cell.Selected = true;
I got NullReferenceException
If I replace first if with the second one – it works.
The value in a cell that you are accessing seems to contain a null value. You are then calling .ToString() on that null value. You could do a null check before you try to call .ToString() on that value.
You would do that with: