Visual C# | DataGridView events exercise | The CellValidating event of a DataGridView



Software ==> Visual C#  (79 exercises)
Version ==> Any version of C#
Topic ==> DataGridView events  (3 exercises)
Level ==> Average difficulty


Create a data source for the Mortgage database in the folder shown above, if you haven't already done so.

Create a form called frmApplicant to contain a DataGridView listing mortgage applicants from the Person table (you may be able to use a version of this form that you've already created):

Visual C Sharp 2010 exercise - DataGridView events (image 1)

Our initial DataGridView

Add code to the CellValidating event of the DataGridView so that when a user enters an invalid amount the application displays an error message, and the user can not leave the cell without correcting the error:

Visual C Sharp 2010 exercise - DataGridView events (image 2)

You can only enter numerical amounts

Add code to display the ErrorText property of the current row if the mortgage type id is not an integer between 1 and 5:

Visual C Sharp 2010 exercise - DataGridView events (image 3)

Don't forget to reset the ErrorText property when a cell is successfully validated

When everything is working OK, close down this form.

This page has 0 threads Add post