title: nullreferenceexception in gridview when header is clicked
body: <p>In my DataGridView selectionChange i have this code, so when the row change the texbox also changes. the code below works, i click the row and it displays right, also when i press up/down arrows. My problem is when I click somwhere in the <code>Header</code> of the grid i have this nullreferenceexception error <code>Object reference not set to an instance of an object.</code>. I don't have idea how to handle it, since i down know what it returns.</p>
  
  <pre><code>Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
      Dim index As Integer
      index = DataGridView1.CurrentCell.RowIndex '&lt;&lt;&lt;&lt;--problem here when I click the header
      If (index &lt;= maxrows - 1) Or (index &lt;&gt; Nothing) Then
          TextBox2.Text = DataGridView1.Item(1, index).Value()
          TextBox3.Text = DataGridView1.Item(2, index).Value()
          TextBox4.Text = DataGridView1.Item(3, index).Value()
      End If
  End Sub
  </code></pre>