Re: Exception in property in Windows Forms DataBinding
From: Giles (Giles_at_discussions.microsoft.com)
Date: 10/31/04
- Previous message: Oliver Lundt via .NET 247: "Databindings and Relationships"
- Next in thread: Piotrek: "Re: Exception in property in Windows Forms DataBinding"
- Reply: Piotrek: "Re: Exception in property in Windows Forms DataBinding"
- Messages sorted by: [ date ] [ thread ]
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
> > >
> > >
> > >
>
>
>
- Previous message: Oliver Lundt via .NET 247: "Databindings and Relationships"
- Next in thread: Piotrek: "Re: Exception in property in Windows Forms DataBinding"
- Reply: Piotrek: "Re: Exception in property in Windows Forms DataBinding"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|