Datagridview validating input
In the previous section we saw how to import Microsoft Excel 12.0 Object Library in the C# project .
Create Excel file from CSharp Data Validation Input Messages is using to embed a message in cells in an Excel Spread Sheet.
The following image shows how a Data Validation Input Message after embedded in an Excel cell.
If you play around with the Data Grid in Silverlight and try some scenarios, maybe you come around the Format Exception with the Message “Input String is not in a correct format”. has a Property of type int and the user enters some characters in the Data Grid.
Data Grid View control is a Windows Forms control that gives you the ability to customize and edit tabular data.
In this short snippet, we will populate a Data Grid View using the Load Data() method.
Normally you would create a View Model that encapsulates the Person-class and contains the additional property.
In my case I implement the Property directly in the Person-class. Inside that property you can then throw your own Format Exception with your special text.
In a Win Form I'm doing initial validation in the Form. To make the code short only three fields are shown in the code.In the Property itself you can’t do anything, because the Exception is thrown before the Age-Property is set.