title: Get Selected Row in DataGridView not working VB.Net
body: <p>I have a pretty standard DataGridView and have already used </p>
  
  <pre><code>.SelectionMode = DataGridViewSelectionMode.FullRowSelect
  .MultiSelect = False
  </code></pre>
  
  <p>in order ensure the entire row is selected. </p>
  
  <p>Situation : I need to obtain the selected row in order to load the data in the row to another screen to "Modify" the data. I am using the following to get the Selected Row.</p>
  
  <pre><code>Private Sub DataGridView2_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView2.CellContentClick
      Try
          If e.RowIndex &gt;= 0 Then
              Dim row As DataGridViewRow
              row = Me.DataGridView2.Rows(e.RowIndex)
              GlobalVariables.SelectedlineItemRowNo = e.RowIndex ' Or row
              MsgBox("GlobalVariables.SelectedlineItemRowNo is ---&gt; " &amp; GlobalVariables.SelectedlineItemRowNo)
  
              'textboxTst.Text = row.Cells("Description").Value.ToString
          End If
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  End Sub
  </code></pre>
  
  <p>Question : The problem is that most of the time when one clicks on the data within the DGV the code above is run and sets the e.RowIndex - BUT when I hit any white space on the row nothing happens and so results in the problem of using the previous row selected, which is in fact the wrong row.?</p>
  
  <p>Any ideas would be appreciated. 
  Thanks in advance </p>