Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Handling Exceptions in BindingNavigator - Bug?

26 views
Skip to first unread message

Zaf

unread,
May 21, 2006, 2:17:00 AM5/21/06
to
I seem to have found a conundrum with the BindingNavigator control.

I have been racking my brain on this problem for awhile, and finally
have reduced the problem to a very simple project.

Problem Summary:
****
When an exception is raised by the data source (such as a DataSet
DataTable) due to a constraint violation (such as Not Null or Duplicate
Primary Key) the BindingNavigator doesn't catch the Exception, and it
ends up at the Application.Run point of the program before it can be
caught.

What Should it Do:
****
There must be a way to catch the Exception, possibily there should be a
new event (named DataError?) that gets raised by the BindingNavigator
when it catches an exception on a BindingSource.EndEdit()

Work Arounds:
****
I have found only one work around, to not use a BindingNavigator and
implement its functions using my own toolbar buttons. The exception in
question gets raised on the BindingSource.EndEdit(), which is a good
place to catch it.

Obviously an ideal solution would utilize an errorProvider control to
indicate to the user where the problem is, but I haven't got a clue how
to implment this.

Example:
***
I have uploaded a Visual C# Project to http://zaf.geek.nz/DataTest.zip
This project demonstrates the problem quite clearly. The steps to
reproduce the problem are:
1) Run the project
2) If there are no "widgets" already present, then add one widget.
(Click Add, then set name="abc" Price="123")
3) Click the Add button on the navigator (the Plus symbol)
4) Set the name field to "abc" (the same as the previous widget)
5) Click previous record (or any other Navigator button to navigate
away from this record).
6) Exception is raised, and it is caught by the debugger all the way up
the stack at Application.Run

If I have missed how to implement this error checking in a logical way
(other than as I've said above and reimplement BindingNavigator
myself), then please tell me!

0 new messages