Posts Tagged ‘Validation’


 

PrimalForms 2011: Validating the Form – Part 4

Friday, September 23rd, 2011 by David Corrales
In Part 3 we discussed validating techniques. Now in the final part of this series we will discuss how to validate the form as a whole. How to Trigger Validation when the Form is Closing: If you have worked with validation in the past, you may have noticed that the unfocused controls do not trigger validation when the form closes. To get around the issue, you can explicitly tell the form to validate its child controls and react accordingly. A good place to trigger the validation is in the form’s FormClosing event:$form1_FormClosing=[System.Windows.Forms.FormClosingEventHandler]{ #Event Argument: $_ = [System.Windows.Forms.FormClosingEventArgs] #Validate only on…   More »

PrimalForms 2011: Validating the Form – Part 3

Wednesday, September 21st, 2011 by David Corrales
In Part 2 we discussed how to validate a control. Now we will cover some techniques that can be utilize for validation. Validating Techniques: Regular Expressions: For more complex validation, such as validating an email address, you may need to rely on Regular Expressions. Regular expressions are useful because it allows you to match complex data by providing formatting information. In addition, PowerShell has built in support for regular expressions in the form of the –match operator. Example use of a regular expression in PowerShell: "PowerShell" -match "shell" In this example we are matching any string that contains the word…   More »

PrimalForms 2011: Validating the Form – Part 2

Friday, September 9th, 2011 by David Corrales
In Part 1 we discussed the import events and properties that are needed for validation. Now we will discuss how to validate a control.  How do I validate a control? As it turns out, validating controls depends on what type of control and the format of the data you wish to validate. Typically you will be validating text that is provided by a TextBox, but it could also come from a ComboBox where the user can type their selection. As for validating the text, it can range from simply ensuring there is value (i.e., not an empty string) or more…   More »

PrimalForms 2011: Validating the Form – Part 1

Friday, September 2nd, 2011 by David Corrales
A good user interface will validate user input to ensure it is in the correct format. This may come in the form of simply checking if there is an entry for a field, such as a name or a more complex task such as validating an email address. Thankfully WinForms has built in mechanisms to help facilitate data validation. Each control has the following events and properties that are used to validate a form: Validation Events: Validating This event occurs when the control is validating. Validation on a control is triggered when the control loses focus. Use this event to…   More »