Re: Exception in property in Windows Forms DataBinding

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Henrik Skak Pedersen (notavailable_at_nothing.com)
Date: 10/05/04


Date: Tue, 5 Oct 2004 09:56:35 +0200

Hi Sijin,

Thank you very much for your reply.

I am using the same code from both the UI and from code. Should I then both
throw an exception and set the error property?

Henrik Skak Pedersen

"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
news:%23IWV1ApqEHA.372@TK2MSFTNGP12.phx.gbl...
> Hi Henrik,
>
> What i meant was that instead of throwng an exception you should set the
> error property in the IDataErrorInfo interface, that ways the UI knows
> that there is an error in your object.
>
> Sijin Joseph
> http://www.indiangeek.net
> http://weblogs.asp.net/sjoseph
>
> Henrik Skak Pedersen wrote:
> > Hi,
> >
> > Thank you very much for your answer. I have allready tried that and I
know
> > that I have to implement the IDataErrorInfo interface to show errors in
the
> > ErrorProvider. But how do I catch exceptions?
> >
> > Henrik.
> >
> >
> > "Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
> > news:eY829uHqEHA.556@tk2msftngp13.phx.gbl...
> >
> >>Use the IDataErrorInfo interface in this case,
>
>>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/
html/vbnet02252003.asp
> >>
> >>this article show how.
> >>
> >>Sijin Joseph
> >>http://www.indiangeek.net
> >>http://weblogs.asp.net/sjoseph
> >>
> >>
> >>Henrik Skak Pedersen wrote:
> >>
> >>>Hi,
> >>>
> >>>I have a problem with exceptions in data binding.
> >>>
> >>>I have a normal windows form with 2 fields on which binds to an Custom
> >>>List which inherits from CollectionBase and imlements IBindingList and
> >>>IEditableObject.
> >>>
> >>>I would like to throw an exception in one of the bound properties if
the
> >>>user enters an invalid value. Like this:
> >>>
> >>>public string Id
> >>>{
> >>> set
> >>> {
> >>> if(value == invalidValue)
> >>> throw new Exception("Inavlid Field Value");
> >>>
> >>> this.id = value;
> >>> }
> >>> get { return this.id; }
> >>>}
> >>>
> >>>The following happens. When the exception is thrown I am not able to
> >>>leave the field (that is ok). But I am not able to see the exception
> >>>anywhere, because it is probably caught by the Binding system.
> >>>
> >>>I would like to display the exception in a MessageBox or display it
using
> >>>the ErrorProvider. How is that possible?
> >>>
> >>>Best regards
> >>>
> >>>Henrik Skak Pedersen
> >
> >
> >



Relevant Pages

  • Re: Exception in property in Windows Forms DataBinding
    ... - Im binding a text box to a custom ... to establish that an error has been thrown and indicating this in an ... >> What i meant was that instead of throwng an exception you should set the ... >> error property in the IDataErrorInfo interface, ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: Exception in property in Windows Forms DataBinding
    ... What i meant was that instead of throwng an exception you should set the ... error property in the IDataErrorInfo interface, ... > that I have to implement the IDataErrorInfo interface to show errors in the ... >>Sijin Joseph ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: error handling when updating a datasource via a data adapter
    ... theres a Error property which is a ... exception object that you can look for the type of error. ... HTH ... i would like the stored procedure to throw an exception ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: customizing validation script-injection error page.
    ... All exceptions can be captured in two places, using event handlers: ... Page object has the Error property ... Your task is to test the class of exception object and redirect to the ... and "Visual Input Security" at http://www.peterblum.com/vise/home.aspx ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: error handling when updating a datasource via a data adapter
    ... Regards ... > handler for that event. ... >> trap the DataAdapters RowUpdated event, theres a Error property which is ... >> exception object that you can look for the type of error. ...
    (microsoft.public.dotnet.framework.adonet)