View Single Post
  #1 (permalink)  
Old November 12th, 2004, 03:47 PM
ja8261 ja8261 is offline
Authorized User
Join Date: Aug 2004
Location: OKC, OK, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating a Datagrid

I am trying to create a Datagrid to import and edit from text and csv files. If I was to import into Excel and use the Text to Columns feature they would have 34 columns. With this in mind I need a Datagrid that has 34 columns. I am just now learning how to create datagrids. This is what I have so far:

Private Sub FormatGrid()
        Dim Tbl As New DataTable
        Dim Col1 As New DataColumn

        Col1.DataType = System.Type.GetType("System.Int32")
        Col1.ColumnName = "Date"
        Col1.AutoIncrement = True
        Col1.Caption = "Date"
        Col1.ReadOnly = True

        datagridOutput.DataSource = Tbl
end sub

I'm not sure if this is the best way to create a datagrid but it was the first way I learned how. As you can see the problem I have is that I will have to declare 34 variables for each column and then go through the process of defining each column like I have done. Is there a way that I can declare the columns in an array as well as the heading names in an array and then create a loop that will run 34 times to create the datagrid with 34 columns with their heading names? Maybe someone could give me a code snippet that would show how to accomplish this.


Jeff Armstrong
Sr. Systems Mgr
SBC Services, Inc.
Jeff Armstrong
Sr. Systems Mgr
SBC Services, Inc.