After getting some good help through this newsgroup I have finally figured
out one way to populate a DataGrid programmatically ... specifically by
using a Data Table, adding columns then rows to it and then binding it to
the DataGrid. Here is a simplified version of my code:
Dim DT as New DataTable
Dim DR as DataRow = DT.NewRow
DT.Columns.Add("Col. A")
DT.Columns.Add("Col. B")
For i = 1 to 3
Dim DRX as DataRow = DT.NewRow
DRX.Item(0) = i
DRX.Item(1) = 4 * i
DT.Rows.Add(DRX)
Next i
DataGridView1.DataSource = DT
When I run this code I only see the heading row [Col. A and Col. B] and one
detail row [with 1 in the first column and 4 in the second column]. I don't
understand why I don't see all three detail rows. Can someone explain this
and tell me where I am messing up?
Thanks very much.