Re: Exception in property in Windows Forms DataBinding

From: Giles (Giles_at_discussions.microsoft.com)
Date: 10/31/04

  • Next message: Scave: "Master-Child DataRelation binding."
    Date: Sun, 31 Oct 2004 05:52:02 -0800
    
    

    Hi,

    Have you found a solution to this yet?

    I am experiencing a similar problem. - Im binding a text box to a custom
    class (that throws exceptions when the value is not correct). if the value
    is not correct the focus does not move out of the text box. Is there any way
    to establish that an error has been thrown and indicating this in an
    errorprovider?

    cheers,

    Giles

    "Henrik Skak Pedersen" wrote:

    > 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
    > > >
    > > >
    > > >
    >
    >
    >


  • Next message: Scave: "Master-Child DataRelation binding."

    Relevant Pages

    • 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, ... >> ErrorProvider. ...
      (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)
    • JTable suddenly "forgets" my custom TableCellRenderer
      ... for one column I have specified a custom ... But no Exception is thrown, so I don't know where the ... I don't do dynamic changes to the structure of the table after it has ...
      (comp.lang.java.gui)
    • 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)