Yorkshireman2
Programmer
My datagridview is bound to a datatable.
As the form loads a filter is applied to the datatable and the datagridview_CurrentCellChanged event fires.
In this event, an exception (System.NullReferenceException "Object reference not set to an instance of an object.") is thrown.
To debug, I first print to immediate window the CurrentCellAddress and this prints out {X=-1,Y=-1} which does not see mright, so I am pretty sure the exception is because the current cell address becomes -1,-1 for some reason.
I tried putting in a simple statement ahead of the datatable access statement that caused this, to see if I could at least read the rowindex
Even this throws the exception so it must be the row and cell index rather than the datatable fields.
- has anyone come across this one?? Why did row,col become -1, -1
As the form loads a filter is applied to the datatable and the datagridview_CurrentCellChanged event fires.
In this event, an exception (System.NullReferenceException "Object reference not set to an instance of an object.") is thrown.
To debug, I first print to immediate window the CurrentCellAddress and this prints out {X=-1,Y=-1} which does not see mright, so I am pretty sure the exception is because the current cell address becomes -1,-1 for some reason.
I tried putting in a simple statement ahead of the datatable access statement that caused this, to see if I could at least read the rowindex
Code:
Dim i As Integer = dgv1.CurrentRow.Index
Even this throws the exception so it must be the row and cell index rather than the datatable fields.
- has anyone come across this one?? Why did row,col become -1, -1