Ok, now I understand, and no, Exceptions like that will be eaten, but th=
ere is an alternate way. Using IDataError and possibly INotifyPropertyC=
hanged you can display an error icon next to the control with an illegal=
value. Instead of throwing an exception when you detect an illegal val=
ue you set an error property with the error text. This text will then b=
e displayed if you hold your mouse over the error icon.
Setting this up can be a bit tricky, but I think this article might prov=
ide some ideas. I know I have some code samples somewhere demonstrating=
this as well. I'll see what I can dig up.
http://www.codeproject.com/csharp/DelegateBusinessObjects.asp On Tue, 18 Sep 2007 02:43:17 +0200, Flavio MIANO <flaviomiano@hotmail.co=
[quoted text, click to view] m> wrote:
> Public Class Paziente
>
> Private _Sesso As String
> Public Property Sesso() As String
> Get
> Return _Sesso
> End Get
> Set(ByVal value As String)
> If value IsNot Nothing Then
> value =3D Char.ToUpper(value)
> If value =3D "M" Or value =3D "F" Then
> _Sesso =3D value
> Else
> throw new exception("Error sex must be M or F")
> End If
> Else
> _Sesso =3D Nothing
> End If
> End Set
> End Property
> End Class
>
> when i set Sesso in the form if i set some different from M or F
> occur an error
> and the focus remain in the textbox
>
> how to capture the error message ex.message to display in the user int=
erface
> ?
>
> Thanks
> FLAVIO
>
> end class
> "Morten Wennevik [C# MVP]" <MortenWennevik@hotmail.com> ha scritto nel=
> messaggio news:op.tyotp9fadj93y5@ubuan...
>> On Tue, 11 Sep 2007 23:55:10 +0200, Flavio MIANO <flaviomiano@hotmail=
..com>
>> wrote:
>>
>>> I create a class
>>> I create a form with a bindingsource object with datasource a instan=
ce of
>>> a
>>> object of this class
>>> when a userinterface create an error no event occur in a form
>>> the bindingsourceobj_dataerror don't fire... why
>>>
>>> there is a solution
>>> hot to detect a error raised in a class by a form ?
>>>
>>> thanks in advance
>>> FLAVIO
>>>
>>>
>>>
>>
>> Hi Flavio,
>>
>> BindingSource.DataError is triggered only on currency related errors.=
>> Furthermore, if the offending piece of code is triggered by a windows=
>> event, Windows might silently eat the error as well.
>>
>> If you post a code sample demonstrating the problem I might be able t=
o
>> provide a solution.
>>
>> --
>> Happy coding!
>> Morten Wennevik [C# MVP]
>
>
>
-- =
Happy coding!