Calendar for WinForms | ComponentOne
DateEdit / Data Validation
In This Topic
    Data Validation
    In This Topic

    The DateEdit control supports data validation of two types, pre-validation and post-validation. Pre-validation is data validation of the raw input string, while post-validation is that of the typed value entered by the user.

    The following sections describe pre-validation and post-validation in DateEdit in-detail.

    Pre-Validation

    DateEdit allows controlling pre-validation of input string through the PreValidation property. The control provides various pre-validation options, as follows:

    The following image shows the DateEdit control displaying validation error message.

    Validation error message box

    The following code snippet shows how to set various properties to apply pre-validation in DateEdit.

    C#
    Copy Code
    // apply PreValidation in DateEdit
    dateEdit.PreValidation.CaseSensitive = true;
    dateEdit.PreValidation.ErrorMessage = "Input mismatch with pattern string";
    dateEdit.PreValidation.ItemSeparator = "|";
    dateEdit.PreValidation.PatternString = "00|11";
    dateEdit.PreValidation.Validation = PreValidationType.ExactList;
    

    Post-Validation

    In DateEdit, post-validation is controlled through the PostValidation property. The control provides various options for post-validation , as follows:

    The following code snippet shows how to set various properties to apply post-validation in DateEdit.

    C#
    Copy Code
    // apply PostValidation in DateEdit
    dateEdit.PostValidation.Validation = PostValidationType.ValuesAndIntervals;
    dateEdit.PostValidation.Values = new[] { 1, 2, 4 };
    dateEdit.PostValidation.ErrorMessage = "Wrong";
    dateEdit.PostValidation.CaseSensitive = false;