473,657 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating WinForms Data

Hi There,

I want to be able to validate data entered by a user onto a form.

Different fields will have different validation requirements.

As an example, a text box may only allow numeric, alpha or alpha numeric
entry and/or may have limitations on length or value.

I thought about inheriting a control from one of the standard forms controls
and adding the validation code required but was thinking that this would make
the application heavier than necessary because certain fields only require
certain validation.

I wanted a way to add validation only where required so thought of creating
a validator object which could have various validationRule objects added as
required.

The validator could respond to events like textChanged on a text box and
where it would then check the rules that had been applied.

I thought that the validationRule object would be either abstract or
impliment specific interface.

I like the GOF 'Chain of Responsibility' pattern as a way of getting the
rule objects to respond to a message from the validator however, I don't know
how to ensure that all the rule objects have received/responded to the
message.

Does this concept make sense? Is this the best way to go about validating
user input? Is this pattern appropriate in this example?
Your thoughts/ideas/comments appreciated.
Regards

Wayne Phipps
Feb 2 '06 #1
0 1803

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1369
by: Mike | last post by:
Hi, In one of my winforms I am validating a textbox making sure it was filled out and that the data is numeric and setting e.Cancel = true if not. Everything works fine however the form has a OK and Cancel button. I do not want the user be able to submit the form if the data is not correct (which works fine by setting e.Cancel = true) however I want to the user to be able to hit cancel and which closes the form. Right now by setting...
10
2401
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ComboBox.SelectedValue = db_value; If the db_value was not included in the ComboBox value list the ComboBox.SelectedIndex used to return -1, Now the very same code is
2
4929
by: Ken Loomis | last post by:
Hello: Using WinForms, certain users may change the value in a combobox, others may not. Some of these boxes open with a default value. I need to check the user's rights before committing his or her changes in the box and restore the previous value if he or she is not allowed (or not let the value be changed in the first place).
0
2432
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that article and recreated the situation I see in my application. (Code included below.) If you run the...
4
3934
by: 3Cooks | last post by:
I have a windows application written in Visual Basic 6.0 that is going to be redeveloped in dotNET. We are trying to decide if we should deploy using Webforms or Winforms and I need advice from someone who is not on my team. The VB 6.0 application is used by approximately 100 users. All users reside in-house. There is an existing external website that will use some of the same components but the two applications are separate. The...
4
2476
by: easoftware | last post by:
I am using VS .Net 2003 and VB. I have an app with one parent and two Mdi child forms. I need to validate data in the Mdi form. The Form.Validating event works when I try to close a Mdi form, but not when I try to switch form one Mdi form to the other. I tried to add code to MdiForm1's Deactivate event: Private Sub MidForm1_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate Dim TempE As...
8
4124
by: Peted | last post by:
I have an amazing problem which i think i have no hope of solving Im working with a c# dot net module that is hosted by and runs under a delphi form envrioment. Dont ask me how this insanity has prevailed it just is :) My problem is this im trying to validate the contents of a textbox (it has to be a normal textbox) and on a c# winforms and i am calling the textbox validating
3
2035
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello everyone, I have an application windows , framework 2.0 + vs2005, and forms, with textboxes that I have validations of their values. Which is the fastest way to do this? using validation with Enterprise Library? using errorProvider Validating and events? Please, samples codes about it...
23
4519
by: raylopez99 | last post by:
Here I am learning WinForms and two months into it I learn there's a WPF API that is coming out. Is this WPF out yet, and is it a threat to WinForms, in the sense that all the library routines I memorize and/ or familiarize myself in WinForms will disappear in WPF? I did note in one early version of C#, the non-generic "ArrayList" was replaced by the generic and template <based List, but that kind of change is not a big deal. If WPF...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.