e.Cancel being set before Validating() event

Posted by: pauld on 19 June 2025, 4:43 pm EST

  • Posted 19 June 2025, 4:43 pm EST

    We are validating a date in a C1DateEdit control.

    When we input a bogus date (eg. 1/33/2025), our code in the Validating() event is showing that the e.Cancel value is already set to TRUE.

    Presumably this is because of PreValidation but we have removed the PreValidating() event handler from our date control.

    That being the case, why are we still seeing e.Cancel has already been set to TRUE in the Validating() event?

    Thanks.

    – Paul

  • Posted 20 June 2025, 6:24 am EST

    Hello Paul,

    In PreValidation, C1DateEdit checks whether the entered string is valid. By default, C1DateEdit.PreValidation.Validation is set to C1.Win.Input.PreValidationType.ExactList, and the C1DateEdit.PreValidation.PatternString property is empty, so there’s no list for the control to validate against. As a result, any input date will pass PreValidation.

    However, after that, the control tries to parse the input and set it as the value. If the input is invalid, parsing will fail, and this sets

    e.Cancel
    to
    true
    .

    So this behavior seems to be by design. Let us know if you have any further questions.

    Regards,

    Uttkarsh.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels