Form validation doco

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 months and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Lembasts
Posts: 405
Last visit: Wed Mar 20, 2024 1:40 pm
Has voted: 1 time
Been upvoted: 1 time

Form validation doco

Post by Lembasts »

https://info.sapien.com/index.php/guis/ ... g-the-form

says this:

"Set $_.Cancel to $true when the validation is successful and you wish to continue.

Set $_.Cancel to $false if you wish to cancel the action because of a validation failure."

Isnt it the other way around?
by pauletteh » Wed May 31, 2023 3:50 pm
Thank you for bringing the document inconsistency to our attention. The document has been updated.
Go to full post
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form validation doco

Post by jvierra »

Please reread the page carefully. You may also want to look at how events are routed in forms. What is the next event after "Validating"?

WHen validation fails we want to stop(cancel) processing the event.
User avatar
Lembasts
Posts: 405
Last visit: Wed Mar 20, 2024 1:40 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Form validation doco

Post by Lembasts »

Its the sentence after that that appears contradictory:

"If the Cancel property is set to True in the Validating event, all events that would usually occur after the Validating event are suppressed. In other words, the validating control will retain the focus until the user provides the correct format, even if the user clicks another control such as a button or textbox. I.e., the caret will remain in the textbox until the user enters the correct format."

"the caret will remain in the textbox until the user enters the correct format"
... does not appear to sit with:
Set $_.Cancel to $true when the validation is successful and you wish to continue.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form validation doco

Post by jvierra »

Never-the-less, that is how event routing works in Windows. It has always worked like that. "Cancel" means stop processing all related events in the validation chain. Other events will not be affected.

Set $_.Cancel equal to $true when you wish to STOP processing events.
User avatar
Lembasts
Posts: 405
Last visit: Wed Mar 20, 2024 1:40 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Form validation doco

Post by Lembasts »

If we consult the ultimate source of truth:
https://learn.microsoft.com/en-us/dotne ... validating

... the C# code sets Cancel to True when validation of the email address has FAILED.
Yet the Sapien doco says:
"Set $_.Cancel to $true when the validation is successful"

They cannot both be true.
User avatar
pauletteh
Posts: 6
Last visit: Fri Mar 01, 2024 5:17 pm
Answers: 1

Re: Form validation doco

Post by pauletteh »

Thank you for bringing the document inconsistency to our attention. The document has been updated.
Jett :geek:
SAPIEN Technologies, Inc.
User avatar
Lembasts
Posts: 405
Last visit: Wed Mar 20, 2024 1:40 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Form validation doco

Post by Lembasts »

pauletteh wrote: Wed May 31, 2023 3:50 pm Thank you for bringing the document inconsistency to our attention. The document has been updated.
David - 1, James - 0 :D
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form validation doco

Post by jvierra »

Couldn't get my thick head to see that you were criticizing the documentation and not how to use the event.

Take two points and a chocolate chip cookie. I need one more lemon to make lemonade.
This topic is 9 months and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked