J
Jan Nielsen
Hi
I have a main form showing personal information (name, address etc.) bound
to a dataset.
One of the pieces of information is the Group the person belongs to. This is
selected from a combo box.
If I want to add a new group to the list. I open a new form like this
myfrmAddGroup = New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing
The FrmAddgroup has this constructor:
Public Sub New(ByRef inpds As Dataset)
It then uses this dataset as datasource in a grid.
No problems this far.
But if I open the form and add a new group.
Then close the form
Then open the form and delete a group. (Any group)
I receive the error:
"An unhandled exception of type 'System.IndexOutOfRangeException' occurred
in system.windows.forms.dll
Additional information: No value at index 13."
In the _main_ forms first line (Public Class frmMainForm) .
And I can´t debug it. It does not say where it appeared. (And I of course
have try catch on all functions)
(I have 14 items in the group list)
I added an rowdeleting eventhandler to frmAddGroup and it appears that this
is called one time for each time I open the form. Ie if open and close the
form 5 times the eventhandler is called 5 times when I delete a row.
So it makes sense: it first deletes the row as it is supposed to. index 13
is fine. But then it tries to delete the row at index 13 again. and fails.
How do get rid of the closed instances of the frmAddGroup so this will not
happen?
Any suggestions?
TIA
Jan
I have a main form showing personal information (name, address etc.) bound
to a dataset.
One of the pieces of information is the Group the person belongs to. This is
selected from a combo box.
If I want to add a new group to the list. I open a new form like this
myfrmAddGroup = New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing
The FrmAddgroup has this constructor:
Public Sub New(ByRef inpds As Dataset)
It then uses this dataset as datasource in a grid.
No problems this far.
But if I open the form and add a new group.
Then close the form
Then open the form and delete a group. (Any group)
I receive the error:
"An unhandled exception of type 'System.IndexOutOfRangeException' occurred
in system.windows.forms.dll
Additional information: No value at index 13."
In the _main_ forms first line (Public Class frmMainForm) .
And I can´t debug it. It does not say where it appeared. (And I of course
have try catch on all functions)
(I have 14 items in the group list)
I added an rowdeleting eventhandler to frmAddGroup and it appears that this
is called one time for each time I open the form. Ie if open and close the
form 5 times the eventhandler is called 5 times when I delete a row.
So it makes sense: it first deletes the row as it is supposed to. index 13
is fine. But then it tries to delete the row at index 13 again. and fails.
How do get rid of the closed instances of the frmAddGroup so this will not
happen?
Any suggestions?
TIA
Jan