Get a Weak or Strong DataTable Row from a selected DataGridView row.
Private Sub btnGetDataGridViewSelectedRowData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetDataGridViewSelectedRowData.Click
'-----------------------------------------------------------------------------------------------------------------------------------
'Find the first selected row (should only be zero or one since DataGridView1.SelectionMode = FullRowSelect)
'-----------------------------------------------------------------------------------------------------------------------------------
Dim row As Integer = DataGridView1.SelectedRows.Count
Dim selectedRowCount As Integer = _
DataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected)
If selectedRowCount <= 0 Then
MessageBox.Show("First, select a row in the grid above.")
Else
'-----------------------------------------------------------------------------------------------------------------------------------
'Get Weakly Typed DataRow from DataGridView selected Row
'-----------------------------------------------------------------------------------------------------------------------------------
Dim myRow As DataRow = DirectCast(DataGridView1.Rows(DataGridView1.SelectedRows(0).Index).DataBoundItem, DataRowView).Row
'-----------------------------------------------------------------------------------------------------------------------------------
'DataGridView was originally bound to a Strongly Typed DataTable, so get the Strongly Typed DataRow
'-----------------------------------------------------------------------------------------------------------------------------------
Dim myStrongRow = CType(myRow, dsStrongDataSet.dtStrongDataTableRow)
End If
End Sub