all groups > dotnet windows forms databinding > september 2007 >
You're in the

dotnet windows forms databinding

group:

DataError don't go !



DataError don't go ! Flavio MIANO
9/11/2007 11:55:10 PM
dotnet windows forms databinding: I create a class
I create a form with a bindingsource object with datasource a instance 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

Re: DataError don't go ! Morten Wennevik [C# MVP]
9/15/2007 12:00:00 AM
[quoted text, click to view]

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 to provide a solution.

--
Happy coding!
Re: DataError don't go ! Flavio MIANO
9/18/2007 2:43:17 AM
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 = Char.ToUpper(value)
If value = "M" Or value = "F" Then
_Sesso = value
Else
throw new exception("Error sex must be M or F")
End If
Else
_Sesso = 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 interface
?

Thanks
FLAVIO

end class
"Morten Wennevik [C# MVP]" <MortenWennevik@hotmail.com> ha scritto nel
messaggio news:op.tyotp9fadj93y5@ubuan...
[quoted text, click to view]

Re: DataError don't go ! Morten Wennevik [C# MVP]
9/18/2007 6:13:53 PM
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]



-- =

Happy coding!
AddThis Social Bookmark Button