Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Text file with a DataGrid

Text file with a DataGrid

Scheduled Pinned Locked Moved Visual Basic
databasetutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brad Fackrell
    wrote on last edited by
    #1

    Does anybody know anything about using a text file with a DataGrid? I have a tab-delimited text file that I would like to load into a DataGrid and the only information that I can find talks about using a database.:confused: What I would like to do is load all lines with no tabs into column 1, load all lines with one tab into column 2, load all lines with two tabs into column 3, etc. The number of tabs will vary so I would like to be able to create columns as needed (on the fly). Example: Data in column 1 (one Tab) Data in column 2 Data in column 1 (one Tab) Data in column 2 (two tabs) Data in column 3 Data in column 1 Thanks Brad

    U 1 Reply Last reply
    0
    • B Brad Fackrell

      Does anybody know anything about using a text file with a DataGrid? I have a tab-delimited text file that I would like to load into a DataGrid and the only information that I can find talks about using a database.:confused: What I would like to do is load all lines with no tabs into column 1, load all lines with one tab into column 2, load all lines with two tabs into column 3, etc. The number of tabs will vary so I would like to be able to create columns as needed (on the fly). Example: Data in column 1 (one Tab) Data in column 2 Data in column 1 (one Tab) Data in column 2 (two tabs) Data in column 3 Data in column 1 Thanks Brad

      U Offline
      U Offline
      User 565426
      wrote on last edited by
      #2

      You will need to specify weather you are using VB6 or .NET, the code willbe quiet different. Thanks, Daryl

      A 1 Reply Last reply
      0
      • U User 565426

        You will need to specify weather you are using VB6 or .NET, the code willbe quiet different. Thanks, Daryl

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Daryl Morgans wrote: You will need to specify weather you are using VB6 or .NET I'm running .NET. Brad

        U 1 Reply Last reply
        0
        • A Anonymous

          Daryl Morgans wrote: You will need to specify weather you are using VB6 or .NET I'm running .NET. Brad

          U Offline
          U Offline
          User 565426
          wrote on last edited by
          #4

          What you will need to do is create a datatable to store the file in. The following should get you started. Dim dt As New DataTable("MyTable") Dim dc As New DataColumn("Column1") Dim rw As DataRow rw = dt.NewRow() rw("Column1") = SomeValue dt.Rows.Add(rw) MyDataGrid.Datasource = dt

          B 1 Reply Last reply
          0
          • U User 565426

            What you will need to do is create a datatable to store the file in. The following should get you started. Dim dt As New DataTable("MyTable") Dim dc As New DataColumn("Column1") Dim rw As DataRow rw = dt.NewRow() rw("Column1") = SomeValue dt.Rows.Add(rw) MyDataGrid.Datasource = dt

            B Offline
            B Offline
            Brad Fackrell
            wrote on last edited by
            #5

            Cool! That looks like it will get me going in the right direction. Thanks Daryl ;)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups