I'm extracting information from an Excel Spreadsheet and trying to build the DataGridView in code. I found this information very helpful. In debug, everything appears to be right. I have the right number of columns and rows properly formatted but nothing displays on the DataGridView. Why? This is really frustrating.
Dim dTable as New DataTable
For Each currcol As Excel.Range In inputRange.Columns
dTable.Columns.Add(currcol.Value2, GetType(String))
Next
inputRange = objXLWs.Range("A" & HeaderRow + 1 & ":" & EndingColumn & EndingRow)
Dim i as Integer
For Each row As Excel.Range In inputRange.Rows
Dim dataRow As DataRow = dTable.NewRow()
i=0
For Each incell As Excel.Range In row.Columns
dataRow(i) = incell.Value2
i += 1
Next
dTable.Rows.Add(dataRow)
Next
bs4DataPreview.DataSource = dTable ' Set up BindingSource
dgv4PreviewData.AutoGenerateColumns = False
dgv4PreviewData.DataSource = bs4DataPreview
dgv4PreviewData.Show()
dgv4PreviewData.Refresh()
Edited source code to reflect use of DataTable. Still getting nothing on DataGridView.