Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / September 2007

Tip: Looking for answers? Try searching our database.

DataError don't go !

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Flavio MIANO - 11 Sep 2007 22:55 GMT
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
Morten Wennevik [C# MVP] - 15 Sep 2007 09:55 GMT
> I create a class
> I create a form with a bindingsource object with datasource a instance of a
[quoted text clipped - 7 lines]
> 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 to provide a solution.

Signature

Happy coding!
Morten Wennevik [C# MVP]

Flavio MIANO - 18 Sep 2007 01:43 GMT
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

>> I create a class
>> I create a form with a bindingsource object with datasource a instance of
[quoted text clipped - 17 lines]
> If you post a code sample demonstrating the problem I might be able to
> provide a solution.
Morten Wennevik [C# MVP] - 18 Sep 2007 17:13 GMT
Ok, now I understand, and no, Exceptions like that will be eaten, but there is an alternate way.  Using IDataError and possibly INotifyPropertyChanged you can display an error icon next to the control with an illegal value.  Instead of throwing an exception when you detect an illegal value you set an error property with the error text.  This text will then be displayed if you hold your mouse over the error icon.

Setting this up can be a bit tricky, but I think this article might provide 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

> Public Class Paziente
>
[quoted text clipped - 55 lines]
>> Happy coding!
>> Morten Wennevik [C# MVP]

Signature

Happy coding!
Morten Wennevik [C# MVP]


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.