Results 1 to 3 of 3

Thread: Diaplay contents of a CSV File

Threaded View

  1. #2
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    Hi Dennis,

    Here is some code to display CSV data in a datagrid. I realize this reply is a bit late, but it may help someone else.

    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim xDataSet As New Data.DataSet()
            Dim xTable As New DataTable()
            Dim xFile As StreamReader = New StreamReader("C:\csvpath.csv")
    
            With xTable.Columns
                .Add("Column0")
                .Add("Column1")
            End With
    
            While xFile.Peek <> -1
                xTable.Rows.Add(Split(xFile.ReadLine, ",", , CompareMethod.Text))
            End While
    
            xDataSet.Tables.Add(xTable)
            DataGrid1.DataSource = xDataSet
    End Sub
    _Dodger.
    Last edited by Dodger; Sep 7th, 2003 at 05:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width