So I'm using this code to search in all cells:

Code:


    Private Sub Button38_Click_1(sender As Object, e As EventArgs) Handles Button38.Click
        Dim temp As Integer = 0
        For i As Integer = 0 To DataGridView1.RowCount - 1
            For j As Integer = 0 To DataGridView1.ColumnCount - 1
                If DataGridView1.Rows(i).Cells(j).Value.ToString = TextBox1.Text Then
                    MsgBox("Item found")
                    temp = 1
                End If
            Next
        Next
        If temp = 0 Then
            MsgBox("Item not found")
        End If
    End Sub

It seems like it really founds many results but when it finishes the search it shows an Error message:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

System.Windows.Forms.DataGridViewCell.Value.get returned Nothing.



How to solve this problem first?
and if possible I want it to show only the rows containing the cell which has the same given text from Textbox1.

I looked for a tutorial in code bank but wasn't lucky to find one, If there is one please provide me with.