Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
' Make the DataTable and give it columns.
Dim dt As New DataTable("Purchases")
dt.Columns.Add("Selected", GetType(Boolean))
dt.Columns.Add("Item", GetType(String))
dt.Columns.Add("Quantity", GetType(Integer))
dt.Columns.Add("Price", GetType(Single))
' Add data to the DataTable.
dt.Rows.Add(New Object() {True, "Donut", 12, 2.37})
dt.Rows.Add(New Object() {True, "CD-RW Disks", 20, _
16.95})
dt.Rows.Add(New Object() {False, "Laptop Computer", 1, _
995.0})
dt.Rows.Add(New Object() {True, "Cookie", 1440, 37.5})
' Attach the DataTable to the DataGrid.
DataGrid1.DataSource = dt
' Set the table's caption.
DataGrid1.CaptionText = "Purchases"
DataGrid1.CaptionVisible = True
End Sub
|