i was assuming you'd use a text file with a header row as the first row containing the text you want displayed as your dgv column headers. if you just want standard columnheaders:
vb Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim lines() As String = IO.File.ReadAllLines("I:\test.txt") Dim dt As New DataTable For x as integer = 1 to lines(0).split(cchar(vbtab)).length dt.Columns.Add("Column" & x.tostring) Next For x As Integer = 0 To lines.GetUpperBound(0) Dim dr As DataRow = dt.NewRow dr.ItemArray = lines(x).Split(cchar(vbtab)) dt.Rows.Add(dr) Next DataGridView1.DataSource = dt End Sub End Class




Reply With Quote
