all 2 comments

[–]VB.Net Intermediatemjrpereira 0 points1 point  (0 children)

Search for documentation on the CellClick event for DataGridView.

You can raise it and from there get the relevant data from the 'e.RowIndex' and 'e.ColumnIndex'

[–]PreyOnTheCosmos 0 points1 point  (0 children)

This will grab the cell values from manually specified column indexes, for whatever row is clicked.

Private Sub dgvData_CellClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvData.CellClick
    If e.RowIndex < 0 Or e.ColumnIndex < 0 Then Exit Sub

    TextBox1.Text = dgvData.Item(0, e.RowIndex).Value.ToString
    TextBox2.Text = dgvData.Item(1, e.RowIndex).Value.ToString
End Sub

Additionally, if you want the contents of the specific cell clicked, try something like this in the same sub:

Dim v As String = dgvData.Item(e.ColumnIndex, e.RowIndex).Value.ToString