Start New Discussion within our Software Development Community

First, I did search the forum and I found a few topics about this but none of the information seemed to be applicable to what I'm doing.

Anyways.

What I'm working on now is a basic telephone directory.

a Directory text file contains the names of all of the subdirectories.

The subdirectory files contain the names and numbers of all of the students/employees etc.

Anyways. I've actually completed the program itself I just need to get the output formatted properly.

Which leaves me with my problem. I want to output the data to some sort of grid. I'm going to assume DGV since it allows my to name columns(the column headings are simple: Name and Phone number)

However, I cannot figure out how to take data from a textfile and throw it into the DGV.

I know how to do it for a listbox, But I don't want a listbox since it isn't a grid.

Anyways, is there any way I can read my textfile data into an array and then iterate the data and output to the datagrid?

Here is a really scaled-down rendition of what you're describing.
I use LINQ to name the columns and everything falls into place without much effort.

This just grabs the first three characters from each word and separates them into the cells of the grid.

Assuming you have a DataGridView named DataGridView1

Imports System.Linq
Public Class Form1
    Dim lst_strData As New List(Of String) From { _
                      "adsf", "bsdf", "csdf"
                  }

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DataGridView1.DataSource = _
        (
            From strData In lst_strData
            Select New With _
            {
                .one = strData(0), _
                .two = strData(1), _
                .three = strData(2)
            } _
        ).ToList()
    End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.