Groups | Blog | Home
all groups > dotnet windows forms controls > june 2008 >

dotnet windows forms controls : Notifying user of Textbox input error


brad
4/25/2008 1:17:01 PM

I have 20+ Textboxes on a form bound to data fields; some hold dates. If an
invalid date is entered the control prevents the user from moving to another
control (this is automatically handled by the default implementation of
Textbox), but no error message is shown and nothing happens to alert the
user. How can I alert the user to the error without writing code for each
Textbox. DataGridView handles this nicely with a messagebox, but the only
solution I could find for Textbox was to write validation code for each
Textbox. It doesn't seem like I should need to do this since the textbox
knows the data is invalid. What am I missing?
--
brad
4/28/2008 11:17:00 AM

I am dynamically adding these textboxes to the form based on the data to be
edited. What I am looking for is behavior similar to the Visual Studio .NET
Properties window and how it provides an error message if you enter a
property value that is invalid.
--
brad
6/23/2008 10:49:39 AM

Here's the answer:
http://msdn.microsoft.com/en-us/library/aa480734.aspx?wt.slv=ColumnA

I'm a bit disappointed with the amount of effort I had to go through to find
and implement this, not because I mind doing my own research, but because
1) In my opinion the solution was not easy to find
2) I needed to convert the solution from VB to C#
3) it seems like a journey that many others would have gone through, would
have remembered and therefore could have easily helped with (MVPs?) .

brad


[quoted text, click to view]
brad
6/23/2008 10:56:01 AM

I should have mentioned the solution is under the section on "Improved
Handling of Errors and Exceptions"

brad


[quoted text, click to view]
AddThis Social Bookmark Button