[NET6] C1DateEdit validation reopened

Posted by: wknauf on 11 July 2023, 4:35 pm EST

    • Post Options:
    • Link

    Posted 11 July 2023, 4:35 pm EST - Updated 11 July 2023, 4:43 pm EST

    This is a followup to https://www.grapecity.com/forums/winforms-edition/net6-problems-in-c1dateedit-customformat-postvalidation: I found three problems in C1DateEdit validation.

    All issues happen with a custom german format (“dd.MM.yyyy”). I know that this could be replaced by standard format “ShortDate”, but it is just a sample format - in our app we use “ddd dd.MM.yyyy”.

    C1DateEditValidation603.zip

    Problem 1: when entering a partial day value (“1”, “2” or “3”) and pressing “TAB”, the control contains the valid DateTime (the input is handled as “01”, “02” or “03”), but the control still renders “1”, “2”, “3”.

    Problem 2: due to historical reasons, in our C1DateEdit subclass I override “OnValueChanged” and call “C1DateEdit.ParseContent” again. And here, “ParseContent” fails. Maybe this is also the reason why the date is not rendered properly?

    This is shown in the sample: remove the “return” statement in “c1DateEdit2_ValueChanged” so that this code is activated:

    object objhelp;
    ErrorInfo errInfo = this.c1DateEdit2.ErrorInfo;
    ErrorReason errReason = this.c1DateEdit2.ParseContent(out objhelp, errInfo);
    if (errReason != ErrorReason.None)
    {
      MessageBox.Show(this, "Validation failed (Current Value: " + this.c1DateEdit2.Value + "): Error = " + errInfo.ErrorMessage);
    }
    else
    {
      MessageBox.Show(this, "Validation is OK (Current Value: " + this.c1DateEdit2.Value + ")");
    }

    My workaround is to remove the “ParseContent” call in “OnValueChanged” and hope that the current input is always valid. Maybe I did this because we use a timer to trigger “ValueChanged” after typing text and waiting a second.

    Problem 3: it seems “PostValidation” intervals using DateTime values still do not work. In the previous forum thread, I wrote that it works, and in our “real” application it seems to do so. But in my sample, it fails: uncomment line 18:

    this.c1DateEdit2.PostValidation.Intervals.Add(new ValueInterval(new DateTime(2023, 1, 1), new DateTime(2013, 12, 31), true, true));
    

    Now you cannot enter any date in the picker.

    It works with string value intervals:

    this.c1DateEdit2.PostValidation.Intervals.Add(new ValueInterval("2023-01-01", "2023-12-31", true, true));

    Of course, those issues were found only after releasing our app version containing C1DateEdit .603 :-(.

    Best regards

    Wolfgang

  • Posted 12 July 2023, 6:18 am EST - Updated 12 July 2023, 6:26 am EST

    Hi Wolfgang,

    Thanks a lot for providing all the details and the sample project.

    Problem 1: A similar issue was recently reported to the development team. The ETA for the fix is the 2023v2 hotfix release.

    Problem 2: We suspect that the ParseContent method is failing here due to the formatting issue in “Problem 1”. We have reported the issue to the development team for further investigation and will let you know the updates as soon as possible.

    [Internal Tracking ID: C1WIN-30629]

    Problem 3: We tested the PostValidation intervals and they are working fine on our end. We observed that in your sample code, you mentioned the ValueInterval range as

    Min Value → new DateTime(2023, 1, 1)

    Max Value → new DateTime(2013, 12, 31)

    which are not logically correct and thus, show an error. The logically correct values are mentioned as strings in your sample code

    Min Value → “2023, 1, 1”

    Max Value → “2023, 12, 31”

    We changed your sample code to “new DateTime(2023, 12, 31)” and it started working fine on our end. Let us know if we are missing something here or if you are facing any other issues.

    Best Regards,

    Kartik

  • Posted 12 July 2023, 7:12 am EST

    Problem 3: just one word: “D’oh!”

    Sorry for this :wink:

    Best regards

    Wolfgang

  • Posted 4 October 2023, 6:55 am EST

    Hi Wolfgang,

    We are glad to let you know that this issue has been fixed in the latest 2023v2(620) hotfix release.

    (https://www.nuget.org/packages/C1.Win.Input/6.0.20232.620)

    Best Regards,

    Kartik

  • Posted 9 October 2023, 5:07 am EST

    Thanks, I can confirm that it works now.

    Best regards

    Wolfgang

Need extra support?

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

Learn More

Forum Channels