G
Guest
(Reposted from Winforms forum. Not sure where this belongs.)
I'm writing a Winforms project in VB/Dot Net 2.0 and I'm having some trouble
handling the DataError event.
The grid is bound to a filtered binding source. Add is enabled. Part of
the primary key is set by one of the cells in the grid which is in combobox
mode. My main concern is duplicate keys. The combobox cell is the only
problem. The other row fields are either hidden or easy-to-validate text
entry boxes (handled in RowValidating).
What I want to do in DataError is give the user the choice of remaining in
the row to fix it (e.cancel = true) or just dispose of the
changes/additions. If it is
an existing row, virtually anything seems to work fine (such as
<bindingsource.ResetBindings, or nothing for that matter.)
What gives me trouble is a newly added row (I'm even sure 'new' is the right
term, but it is newly added. By the time it gets to DataError, the row's
IsNewRow property = False).
Any attempt to get rid of the new row by any means seems to get me into
some sort of infinite loop back to DataError, with errors like 'Index
<number> does not have a value'.
Am I even trying to handle the error in the right place?
I'm writing a Winforms project in VB/Dot Net 2.0 and I'm having some trouble
handling the DataError event.
The grid is bound to a filtered binding source. Add is enabled. Part of
the primary key is set by one of the cells in the grid which is in combobox
mode. My main concern is duplicate keys. The combobox cell is the only
problem. The other row fields are either hidden or easy-to-validate text
entry boxes (handled in RowValidating).
What I want to do in DataError is give the user the choice of remaining in
the row to fix it (e.cancel = true) or just dispose of the
changes/additions. If it is
an existing row, virtually anything seems to work fine (such as
<bindingsource.ResetBindings, or nothing for that matter.)
What gives me trouble is a newly added row (I'm even sure 'new' is the right
term, but it is newly added. By the time it gets to DataError, the row's
IsNewRow property = False).
Any attempt to get rid of the new row by any means seems to get me into
some sort of infinite loop back to DataError, with errors like 'Index
<number> does not have a value'.
Am I even trying to handle the error in the right place?