title: Read txt data and import into datagridview vb.net
body: <p>I have txt file that contain data something like this</p>
  
  <pre><code>EN^FN^SN^GN^SQ^I48-14^000042^2014-11-19^15:13:45^2014-11-19^^
  </code></pre>
  
  <p>Expected result in datagridview </p>
  
  <pre><code>EN         FN         SN            GN           SQ
  I48-14     000042     2014-11-19    15:13:45     2014-11-19
  </code></pre>
  
  <p>In design form I have 1 button to browse the file directory, 1 textbox to show file name, of course one 1 datagridview to show the result of conversion 
  I'm having this error line </p>
  
  <pre><code>Me.DataGridView1.Rows.Add(SplitLine)
  
  * No row can be added to a DataGridView control that does not have columns. Columns must be added first.
  </code></pre>
  
  <p>This is the code I've tied with no success </p>
  
  <pre><code>Public Class Form1
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
      Dim fName As String = ""
      Dim Ex As OpenFileDialog = New OpenFileDialog()
      'Ex.InitialDirectory = "c:\"
      Ex.Filter = "(*.csv)|*.CSV|(*.txt)|*.txt"
      Ex.FilterIndex = 2
      Ex.RestoreDirectory = True
      If (Ex.ShowDialog() = Windows.Forms.DialogResult.OK) Then
          fName = Ex.FileName
      End If
      Me.TextBox1.Text = fName
      Dim TextLine As String = ""
      Dim SplitLine() As String
      If System.IO.File.Exists(fName) = True Then
          Dim objReader As New System.IO.StreamReader(fName)
          Do While objReader.Peek() &lt;&gt; -1
              TextLine = objReader.ReadLine()
              SplitLine = Split(TextLine, "^")
              Me.DataGridView1.Rows.Add(SplitLine)
          Loop
      Else
          MsgBox("File Does Not Exist")
      End If
  End Sub
  </code></pre>
  
  <p>End Class</p>