Best way to work with a DataGridView is by using its DataSource with a DataTable in this case rather than no DataSource which means later you can access data via the underlying DataTable rather than via the Cells.
Create columns in the designer, set each column's DataPropertyName to a DataColumn in the DataTable.
Namespace CodeSamples
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Populate()
Dim table As New DataTable()
table.Columns.Add("FirstName", GetType(String))
table.Columns.Add("LastName", GetType(String))
dataGridView1.DataSource = table
FirstNameListBox.DataSource = New List(Of String)() From {"Karen", "Mary", "Jim"}
LastNameListBox.DataSource = New List(Of String)() From {"Payne", "Jones", "Smith"}
For index As Integer = 0 To FirstNameListBox.Items.Count - 1
table.Rows.Add( {FirstNameListBox.Items(index), LastNameListBox.Items(index) })
Next index
End Sub
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As EventArgs)
Populate()
End Sub
End Class
End Namespace
Next level, use a BindingSource, here I show how to get the current row in the DataGridView.
Namespace CodeSamples
Partial Public Class Form1
Inherits Form
Private bindingSource As New BindingSource()
Public Sub New()
InitializeComponent()
End Sub
Private Sub Populate()
Dim table As New DataTable()
table.Columns.Add("FirstName", GetType(String))
table.Columns.Add("LastName", GetType(String))
bindingSource.DataSource = table
dataGridView1.DataSource = bindingSource
FirstNameListBox.DataSource = New List(Of String)() From {"Karen", "Mary", "Jim"}
LastNameListBox.DataSource = New List(Of String)() From {"Payne", "Jones", "Smith"}
For index As Integer = 0 To FirstNameListBox.Items.Count - 1
table.Rows.Add( {FirstNameListBox.Items(index), LastNameListBox.Items(index) })
Next index
End Sub
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As EventArgs)
Populate()
End Sub
Private Sub GetCurrentButton_Click(ByVal sender As Object, ByVal e As EventArgs)
If bindingSource.Current IsNot Nothing Then
Dim row As DataRow = CType(bindingSource.Current, DataRowView).Row
MessageBox.Show($"{row.Field(Of String)("FirstName")} {row.Field(Of String)("LastName")}")
End If
End Sub
End Class
End Namespace