Form ExitButton (X) action
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.
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.
Form ExitButton (X) action
Im running input validation checks on FormClosing event, this means if I try close the form via the Exit button (top right) I hit validation issues. Is there a way to check if the X button has been clicked to bypass the validation on Exit button click?
Re: Form ExitButton (X) action
Then I wont be able to close the form unless I complete all fields. Is there a way to check if any button has been clicked? Surely there must be a bool somewhere?
I tried defining a bool variable in GLobals then setting it to true in th OKButtonclick event but when querying it in the closing event it reads incorrectly.
I tried defining a bool variable in GLobals then setting it to true in th OKButtonclick event but when querying it in the closing event it reads incorrectly.
Re: Form ExitButton (X) action
I posted an example of how to close and cancel a form. You cannot detect if the "X" has been clicked. The code posted shows you how to deal with the closing issue. If you need something else then you will have to learn how forms work and ask a better question.
You can set a variable in any event and that will be visible anywhere in the form and in any event. You have to "scope" the variable when assigning it or the change will be lost when the event exits.
You can set a variable in any event and that will be visible anywhere in the form and in any event. You have to "scope" the variable when assigning it or the change will be lost when the event exits.
Re: Form ExitButton (X) action
So I'm keeping the exit button, I just defined the scope for the variable in Globals and its working as expected now.
Although your comments are a little dismissing and presumptuous I do appreciate the help. A ref to your "post" would have been useful however, the mention of scope was in fact useful. Thank you
Although your comments are a little dismissing and presumptuous I do appreciate the help. A ref to your "post" would have been useful however, the mention of scope was in fact useful. Thank you
Re: Form ExitButton (X) action
I attached a full example for everything you asked in the beginning. I couldn't understand why you kept asking the same question after I had answered it three different ways.
Without a good understanding of PowerShell basics using form will be a challenge. Also look at the articles and examples in the info center to get a better idea of how forms work.
Without a good understanding of PowerShell basics using form will be a challenge. Also look at the articles and examples in the info center to get a better idea of how forms work.
Re: Form ExitButton (X) action
Yes I'm not familiar with forms, but I have some experience in Powershell but mostly python, Ive resolved the problem nonetheless. I wanted to keep the control box and as this is the first form Ive ever created I wasn't sure on the best location to carry things like validation but now I know the flow a bit better, and understand the event triggers (im new to GUIs in generally, always been a terminal guy) Ive setup input validation on all fields (multiple child forms), setup local logging and error output, terminal logging (gui). I will setup a SYSLOG function on specific events next. Thanks again