Results 1 to 2 of 2

Thread: DataGrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Location
    WestCoast - Cali
    Posts
    116

    DataGrid

    How do you setup a datagrid and it's columns? Does the database need to be binded first or can i just do the design first?

    Thanks

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    You can do the design first if you want. That's the way i usually do it.
    Code:
    Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      SetUpData()
    End Sub
    
    Public Sub SetUpData()
     Dim cdCollection As DataTable 
     Dim ds As DataSet
     Dim datarow As DataRow
     Dim idColumn As DataColumn
     Dim titleColumn As DataColumn
    
     cdCollection = New DataTable("Cd Collection")
     idcolumn = New DataColumn("id")
     idColumn.AutoIncrement = True
     idColumn.DataType = Type.GetType("System.Int32")
     cdCollection.Columns.Add(idColumn)
    
     titleColumn = new DataColumn("Cd Title")
     titleColumn.DefaultValue = "<Title not available>"
     titleColumn.DataType = Type.GetType("System.String")
     cdCollection.Colums.Add(titleColumn)
    
     datarow = cdCollection.NewRow
     datarow("Cd Title") = "Andrew WK"
     cdCollection.Rows.Add(datarow)
    
     ds.Tables.Add(cdCollection)
    
     DataGrid1.SetDataBinding(ds,cdCollection) 
    
    End Sub

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