Results 1 to 16 of 16

Thread: partial .txt file to datagridview using vb.net

Threaded View

  1. #6
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,407

    Re: partial .txt file to datagridview using vb.net

    I noticed something in my code, change this line:
    Code:
    dt.Columns.AddRange((From column As String In lines.First.Split(";"c) Select New DataColumn(column)).ToArray())
    To this:
    Code:
    dt.Columns.AddRange((From columnIndex As Integer In Enumerable.Range(1, lines.First.Split(";"c).Count) Select New DataColumn("Column" & columnIndex.ToString())).ToArray())
    The adjustment will name the columns: Column1, Column2, etc. rather than naming them the respective values in the first row.
    Last edited by dday9; Feb 11th, 2016 at 01:27 PM. Reason: changed column to row
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

Tags for this Thread

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