.CSV a DataGridView Filas que aparecen en blanco en VB.NET
Aquí están los datos CSV que estoy tratando de importar en mi aplicación VB.NET:
Pero cuando lo ejecuto a través de la aplicación, solo llena la última fila:
Aquí está el código para la importación:
Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click
DataGridView1.ClearSelection()
ofd.Filter = "(*csv)|*.csv"
If ComboBox1.Text = "zVBImportTEST" Then
If (ofd.ShowDialog() = DialogResult.OK) Then
txtbxFilePath.Text = ofd.FileName
End If
Dim colsexpected As Integer = 6
Dim thereader As New StreamReader(txtbxFilePath.Text, Encoding.ASCII)
Dim sline As String = ""
thereader.ReadLine()
Do
sline = thereader.ReadLine
If sline Is Nothing Then Exit Do
Dim words() As String = sline.Split(",")
DataGridView1.Rows.Add("")
For ix As Integer = 0 To 5
DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(ix).Value = words(ix)
Next
Loop
thereader.Close()
Else
MessageBox.Show("Please select a project.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End If
End Sub
Parece que no puedo entender por qué las otras filas están en blanco. Si alguien pudiera ayudarme, sería muy apreciado.