Re: Exception in property in Windows Forms DataBinding
From: Henrik Skak Pedersen (notavailable_at_nothing.com)
Date: 10/05/04
- Next message: Jesper: "Databinding multiple rows?"
- Previous message: Sijin Joseph: "Re: Exception in property in Windows Forms DataBinding"
- In reply to: Sijin Joseph: "Re: Exception in property in Windows Forms DataBinding"
- Messages sorted by: [ date ] [ thread ]
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
> >
> >
> >
- Next message: Jesper: "Databinding multiple rows?"
- Previous message: Sijin Joseph: "Re: Exception in property in Windows Forms DataBinding"
- In reply to: Sijin Joseph: "Re: Exception in property in Windows Forms DataBinding"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|