HI, after days of checking the code i found wich line the error makes appear
It is grd.Rows.Count = 2. When i set to 3 or higher the error disapears.
But i dont wont empty rows, on load of the rows i wanna start with the 2 rows, on is the caption row and one is the footer row.
When i set it to 3 then there is a row at the start of the table that we dont need
Here is a short verion of my code: Cursor = Cursors.WaitCursor
grd.Redraw = False
** grd.Rows.Count = 2****
Dim drDaten As DataTableReader
grd.Cols.Count = grd.Cols(“Schlussel”).Index + 1
AddColsToGrid(grd, False, True, False, “#,##0.00”, True, grd.Cols.Count, “B_”)
grd.Cols(“Schlussel”).DataMap = GetSchlussel(False)
drDaten = ReadSQL(“SELECT * FROM Table WHERE Betrieb ='” & sBetrieb & “’ AND Periode =” & nPeriod & " AND Jahr=" & nJahr & " ORDER BY OrderRow")
While drDaten.Read
grd.AddItem(“”)
grd(grd.Rows.Count - 2, “Row”) = grd.Rows.Count - 3
grd(grd.Rows.Count - 2, “Code”) = drDaten!Code
CalRow(grd(grd.Rows.Count - 2, “Row”) + 1, grd)
myKORE.GetSchlüssel(“Keys”, grd.Rows.Count - 2, grd, grd(grd.Rows.Count - 2, “Schlussel”))
End While
drDaten.Close()
bLoad = False
grd.Redraw = True
SaveGridSum()
Cursor = Cursors.Default