Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1878
UltraTextEditor - Exception Handling with Data Binding
posted

Hi,

I'm doing data binding for the controls on my User Control using System.Windows.Forms.BindingSource. I've several UltraTextEditor controls on that User Control that are using this BindingSource to exchange the data with my business object interworking with the database. That works pretty well both for getting data from the database as well saving it back.

I want to throw exceptions out from the business object for error cases with the data/database/... when setting of the related property in the business object fails so I tested the behaviour but it seems that the exception is caught somewhere in between the business object and my User Control. I see the exception in the output window and when I try to leave the focus of the UltraTextEditor by pressing TAB this is not possible. It's also not possible to close the entire application as long this error condition exists.

Any ideas how I can get the exceptions into "my" code and handle it their!

Kind regards,
  Wolfgang

Parents
No Data
Reply
  • 1878
    Offline posted

    Hi,

    I've found it out by myself now how to handle it. Btw it's nothing specific to Infragistics Controls but to BindingSource objects from Microsoft. This class offers a BindingComplete event that can be subscribed in user code. This event has a state that can be checked if it is set to success and if not some error has occured during binding that either can be shown to the user, written into logfile, ....

    Following example illustrates this:

    private void OnBindingComplete(object sender, BindingCompleteEventArgs e)
    {
      if (e.BindingCompleteState != BindingCompleteState.Success)
      {
        MessageBox.Show(e.ErrorText, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        e.Cancel = true;
      }
    } 

    Kind regards,
      Wolfgang

Children
No Data