I'm working on a toolbox app for our IT department and one of the functions used all the time is New User Creation. In our project it opens a second form, aduserForm.psf, with all the fields listed. What I'm trying to do is clear the fields when the form is closed by not using Submit (so using the Form Control X button), or just not send the field data back to the main form if Submit is not used.
Is there a way to make that distinction for form.close()?
Clear Fields or Not Submit Data on Form Close
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.
- fbhl_itdept
- Posts: 1
- Last visit: Thu Sep 29, 2022 9:46 am
Re: Clear Fields or Not Submit Data on Form Close
There is no "Submit" button on a form. You are thinking of HTML forms. PowerShell Studio WinForms always lose all data when closed. Re-opening a form will have it open with whatever defaults have been set in the form.
WinForms do not send data back to the calling form. In PSS the forms controls are made available to the calling form as special variables. If you want those variables to be cleared then you will have to write code to do that. There is no automatic way to do that.
WHen a "Dialog" closes the close method can set the "DialogResult" which is returned as the result of the function that opened the form. This value will tell you what kind close was intended.
See the following as a place to start.
https://www.sapien.com/blog/2015/12/23/ ... logresult/
WinForms do not send data back to the calling form. In PSS the forms controls are made available to the calling form as special variables. If you want those variables to be cleared then you will have to write code to do that. There is no automatic way to do that.
WHen a "Dialog" closes the close method can set the "DialogResult" which is returned as the result of the function that opened the form. This value will tell you what kind close was intended.
See the following as a place to start.
https://www.sapien.com/blog/2015/12/23/ ... logresult/