Data validation in Spread for WPF allows you to control the type of data that users can enter into the cells. You can limit the range of acceptable values or restrict entries to a specified format, such as text, numbers, dates, and more. This feature helps prevent errors and ensures data consistency by restricting invalid data entry.
There are various ways in which data can be validated such as restricting invalid input keys and displaying error or warning messages. The following table lists different types of data validation alerts that can be triggered when users enter invalid data.
Alert Type | Description | Options |
Stop | Prevents users from entering invalid data in a cell or cell range. When this alert appears, you must enter a value that must satisfy the data validation criteria specified for the cell. |
|
Warning | Warns users that the data entered in the cell or cell range is invalid. |
|
Information | Informs users that the data is invalid but does not prevent them from continuing. |
|
Spread for WPF supports several types of data validation, which can be applied using the DataValidationType enumeration in the GrapeCity.Spreadsheet namespace.
This type of validation checks if the value entered in a cell, is a whole number. Number validation stops users from entering numbers that fall outside the specified criteria. Use the WholeNumber property of the DataValidationType enumeration to apply this validation.
This type of validation ensures users only enter decimal numbers in a cell or range of cells. Use the Decimal property of the DataValidationType enumeration to apply decimal validation in the worksheet.
This type of validation checks that the input matches a value from a predefined list present in the cell. Use the List property of the DataValidationType enumeration to apply list validation in the worksheet.
This type of validation ensures that the entered data in the cell or cell range is in a valid date format. It restricts users from entering an invalid date based on the criteria you specified for the cell. Use the Date property of the DataValidationType enumeration for date validation.
This type of validation checks the time entered in the cell or cell range. It restricts invalid time entries based on your specified criteria. Use the Time property of the DataValidationType enumeration to apply time validation in a worksheet.
This type of validation limits the number of characters that a user can enter in a cell or cell range. It is useful when limiting input, such as setting a maximum character count. Use the TextLength property of the DataValidationType enumeration to apply text length validation.
This type of validation allows you to create your own rules to check the formulas entered in a cell or cell range. Use the Custom property of the DataValidationType enumeration to apply custom formula validation in a worksheet.