c1DateEdit.Undo

Posted by: softcomlimited on 7 April 2020, 12:24 pm EST

    • Post Options:
    • Link

    Posted 7 April 2020, 12:24 pm EST

    Hello,

    I am trying to get a c1DateEdit value to undo and revert to the value before the user changed the date to a date that does not fit my business rules. The date is a properly formed date but not in the range I want.

    I tried various things but none change the value back. I tried c1DateEdit.Undo in the Validating event, I tried ErrorActionEnum.ResetValue and various other combinations and no luck.

    Can this be done the way i am thinking?

    Thanks

    Brian

  • Posted 7 April 2020, 6:32 pm EST

    Hi Brian,

    did you try to set “e.Cancel = true” in the “Validating” event handler? This should be enough to reject a wrong input.

    If you want to accept only dates in a valid date range, you can simple set this:

    
    this.c1DateEdit.PostValidation.Intervals.Add ( new ValueInterval (minDate, maxDate, true, true) );
    
    

    Then C1DateEdit will handle the check that the date is in a valid range, without you having to add any code.

    The C1 guys will probably ask for a small sample to reproduce this ;-).

    Best regards

    Wolfgang

  • Posted 7 April 2020, 10:42 pm EST

    Hi Brian,

    If you want to put validation on a given range then you can use the code snippet suggested by @Wolfgang.

    this.c1DateEdit.PostValidation.Intervals.Add ( new ValueInterval (minDate, maxDate, true, true) );
    
    

    We have also created a sample as per our understanding, please have a look and let us know if this fulfills your requirements or not.

    If you are doing something else then please modify the attached sample accordingly.

    Regards,

    Prabhat Sharma.

    C1DateEdit.zip

  • Posted 7 April 2020, 11:32 pm EST

    Thanks for the replies.

    Yes, I did try the e.Cancel and I thought that by setting ErrorActionEnum.ResetValue it would revert the value but all it did was keep the focus in the dateedit and left the incorrect date value in the field.

    I will try the sample and see if I missed something.

    Thanks

    Brian

  • Posted 8 April 2020, 11:39 am EST

    Mr Sharma,

    Am I correct in saying that you to reset the c1DateEdit1.Value back to the original value by using c1DateEdit1.Value = date in the C1DateEdit1_ValidationError event?

    If so this is what I was trying to avoid having to do as it means I have to manually keep track the values of the dateedits just prior to the edit of each.

    I was hoping it was handled automatically by a kind of internal .ResetValue or .Undo

    Regards

    Brian

  • Posted 8 April 2020, 11:08 pm EST

    Hi Brian,

    If you do not want to keep track of the last correct value manually then you can simply use the ResetText method in the C1DateEdit1_ValidationError event to do the same.

    https://www.grapecity.com/componentone/docs/win/online-input/C1.Win.C1Input.4.5.2~C1.Win.C1Input.C1TextBox~ResetText.html

    Regards,

    Prabhat Sharma.

  • Posted 9 April 2020, 12:12 am EST

    Ahh, ok, will try that.

    Thanks

    Brian

  • Posted 9 April 2020, 3:13 am EST

    This is exactly what I needed.

    Thanks

    Brian

  • Posted 11 April 2020, 5:59 am EST

    Mr Sharma,

    With regard to the PostValidation.Intervals, how are the criteria applied if there are multiple intervals? The docs says the input must be within any one but is the order significant? Is there a way to require that all intervals be satisfied?

    Thanks

    Brian

  • Posted 12 April 2020, 9:10 pm EST

    Hi Brian,

    You can add n number of intervals for validation and there is no specific order that needs to be followed for this.

    We did not understand what do you mean by the following phrase:

    Is there a way to require that all intervals be satisfied?



    Regards,

    Prabhat Sharma.

  • Posted 13 April 2020, 12:21 pm EST

    What I meant was using “AND” rather than “OR” for all the conditions. What I ended up doing was taking all the intervals and reducing them down to one. It takes some doing but it works.

    Thanks

    Brian

  • Posted 13 April 2020, 10:22 pm EST

    Hi Brian,

    It’s good to hear that everything is working fine at your end.

    If you have any other queries then please let us know.

    Regards,

    Prabhat Sharma.

  • Posted 13 April 2020, 10:22 pm EST

    Hi Brian,

    It’s good to hear that everything is working fine at your end.

    If you have any other queries then please let us know.

    Regards,

    Prabhat Sharma.

Need extra support?

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

Learn More

Forum Channels