hello, i am having some problems when datagridview(DGV) in visual basic net 2008 pro edition. there are a few tab pages and each tab page has one DGV. each DGV is binded to a dataTable (DT). what i want to do is each table have column heading and row heading. as its a table that i am showing. the snipits of the code used to setup the DGVs is below

        Dim
 dtTemp As
 New
 DataTable()
        Dim
 dgvTemp As
 New
 DataGridView()
        Dim
 tempTable As
 Tables  'my own custom class

        Dim
 x, y As
 Integer



        tempTable = currentEcuSettings.tableAt(tpIndex)


        For
 x = 0 To
 tempTable.totalXElement - 1
            dtTemp.Columns.Add(New
 DataColumn(tempTable.xElementAt(x), GetType
(Double
)))
        Next
 x
        For
 y = 0 To
 tempTable.totalYElement - 1
            dtTemp.Rows.Add()
        Next

        dtTemp.AcceptChanges()
        dgvTemp.DataSource = dtTemp
        dgvTemp.Dock = DockStyle.Fill
        dgvTemp.AllowUserToAddRows = False

        dgvTemp.AllowUserToDeleteRows = False

        dgvTemp.AllowUserToOrderColumns = False

        dgvTemp.AutoResizeColumns()
        dgvTemp.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
        dgvTemp.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
        dgvTemp.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders
        dgvTemp.AllowUserToOrderColumns = False

        tabLiveMaps.TabPages(tpIndex + CONSTInfoTabCount).Controls.Add(dgvTemp)



now i tried to add the row headers in the 2nd loop but it keeps on throwing the above exception. what i have noticed is that after a little bit of time (say 5secs or more) if i run the following code it runs without any exceptions. looks like it takes a little time to load up the datatable

        Dim idx, y As Integer
        For idx = 0 To 'total datagridviewtables, increment through all DGVs
            For y = 0 To currentEcuSettings.tableAt(idx).totalYElement - 1
                Dim str As String
                str = CType(currentEcuSettings.tableAt(idx).yElementAt(y), String)
                CType(dgvTables(idx), DataGridView).Rows(y).HeaderCell.Value = str
            Next y
        Next idx
        'End If