Results 1 to 20 of 20

Thread: CSV to a form ??? please help .... [resolved]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member dinosaur_uk's Avatar
    Join Date
    Sep 2004
    Location
    Jurassic Park
    Posts
    1,098

    Resolved CSV to a form ??? please help .... [resolved]

    Hi there,

    I have a csv file which i would like to display in a control on my form which behaves like excel spreadsheet.

    here is a screenshot of the datatable which i use to put the data on. Is there a more efficient way of doing this ?

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim SR As StreamReader = IO.File.OpenText("badger.csv")
    3.         Dim strFileString As String
    4.         Dim al As New ArrayList
    5.         Dim filetext() As String
    6.         Dim i, j As Integer
    7.  
    8.         Dim dt As New DataTable
    9.         Dim dr As DataRow
    10.  
    11.         Do While SR.Peek <> -1
    12.             al.Add(SR.ReadLine)
    13.  
    14.         Loop
    15.  
    16.         filetext = Split(al(0), ",")
    17.         For j = 0 To filetext.Length - 1
    18.             ListBox1.Items.Add(filetext(j))
    19.             dt.Columns.Add(filetext(j))
    20.         Next
    21.  
    22.         For i = 1 To al.Count - 1
    23.             Dim r As DataRow = dt.NewRow
    24.             filetext = Split(al(i), ",")
    25.             For j = 0 To filetext.Length - 1
    26.  
    27.                 'ListBox1.Items.Add(filetext(j))
    28.                 r(j) = filetext(j)
    29.             Next
    30.             dt.Rows.Add(r)
    31.             '  ListBox1.Items.Add(filetext(3).ToString)
    32.         Next
    33.  
    34.         DataGrid1.DataSource = dt
    35.     End Sub

    Any ideas folks ?
    Attached Images Attached Images  
    Last edited by dinosaur_uk; Nov 5th, 2004 at 07:46 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