I have a datagridview that lists out all orders for a particular customer. You can double click on a line and pull up the details of the order. In this example, the order id is stored in a cell titled OID#
Private Sub dgOrderDataGridView_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgOrdererDataGridView.DoubleClick
'
' Get all available Data for selected order on the grid
Try
If dgOrderDataGridView.CurrentRow.Cells ("OID#").Value Is Nothing Then
'
' If the Order ID # is null then cancel and clear the selected row
dgOrderDataGridView.ClearSelection()
Exit Sub
End If
'
' Request order data
Try
Dim orderer_lookup As Integer
order_lookup = CInt(dgOrderDataGridView.CurrentRow.Cells ("OID#").Value)
'
' Your lookup code goes here. Use order_lookup to link to the database
'
Catch ex As Exception
Finally
End Try
Catch ex As NullReferenceException
'
' NullReferenceException. User dbl clicked an empty datagrid
MsgBox("There are no orders to select", MsgBoxStyle.OkOnly, "No Order Data")
End Try
End Sub
Edited to fix where Yahoo butchered the code.