Hi @Frank Kosterman ,
The part of the code where the rows/columns are added looks fine.
It is recommended that you do step-by-step debugging and use Watch to monitor RowCount and ColumnCount to see at which step the value goes wrong.
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
I don't do it by binding, maybe i should, but the database is choosen during runtime
i understand that it isn't possible that way, but maybe i'm wrong
I have openend an acces database
IIn its recordset i go through all fields and create colums in the datagridview
Then i go through all the records and place the field value in the cells
This is the master datagridview
Now the user can edit the data ,and after he leaves the cell, the code validates the data and saves it to the database
When the user selects a row , data is retrived from another table and and other datagridviews are filled
The user has the option to change the background color of the child datagrids
He can invoke that with the right mouse down
Private Sub DgInschrijvingen_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
Dim nKleur As Color
Dim oKleur As Kleur
If e.Button = MouseButtons.Right Then
oKleur = frmVerzamelstaat.KiesKleur(nPos) ' ' this will call the colordialog box
If oKleur.IsKleurGekozen Then
nKleur = oKleur.GekozenKleur
MyBase.BackgroundColor = nKleur
MyBase.Columns(0).DefaultCellStyle.BackColor = nKleur
Private Sub ColorCell(nRow As Integer, nCell As Integer, kleur As Color)
Me.dgView.Rows(nRow).Cells(nCell).Style.BackColor = kleur <=== Here it goes wrong
'Now store the color in the datbase
Call StoreColor(nRow, nCell, kleur)
II would suggest you put a breakpoint at the line:
Me.dgView.Rows(nRow).Cells(nCell).Style.BackColor = kleur
and examine each of the variables and determine if they are as expected.
If not, then look backward to the call to the 'ColorCell' and further back to see what the values are there and how they are being formed.