Exercise: Code validation for a DataGridView

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> Visual Basic 2010  (42 exercises)
Topic ==> Reacting to DataGridView events  (3 exercises)
Level ==> Average difficulty
Course ==> WinForms using VB
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

If you haven't already done so in this project, create a data source for the Mortgage Access database in the folder shown above.

Create a form called frmApplicant, and within this create a DataGridView to show mortgage applicants from the Person table:

Visual Basic 2010 exercise - Reacting to DataGridView events (image 1)

The DataGridView, with an alternate row style

Add validation such that when the user enters an invalid amount the application displays an error message, and the user can not leave the cell without correcting the error:

Visual Basic 2010 exercise - Reacting to DataGridView events (image 2)

LOTS is not a valid amount!

If you have time, add code to display a suitable value for the ErrorText property of the current row if the mortgage type id is not an integer between 1 and 5:

Visual Basic 2010 exercise - Reacting to DataGridView events (image 3)

should appear if you enter a mortgage type id of 7, for example, as here

Pat yourself on the back, and close down any open forms.

This page has 0 threads Add post