Product, version and build: PowerShell Studio 2019 5.6.164
32 or 64 bit version of product: 64 bits
Operating system: Windows 10
32 or 64 bit OS: 64 bits
So I have a multi-form project, in the first one (frmMain), I have some checkbox fields, user select some of them, and then click on 'Next' button and other form (frmAuth) is shown, what I'm trying to achieve is to keep the checkbox selected if the user tries to return to frmMain form.
I've tried Hide(), Close(), Dispose() (this one being my last resource as it only dispose the form).
Here is the frmMain, which is the first one shown, I've selected three checkbox, and click on 'Next' button.
In this form (frmAuth), I click on 'Back' button, and the checkbox are not selected.
Thanks for your help.
Forms closing and keep checekbox values
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.
-
- Posts: 2
- Last visit: Thu Apr 29, 2021 9:37 am
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Forms closing and keep checekbox values
[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Forms closing and keep checekbox values
Hi Cristian, Your issue is a bit thin. Are you closing the checkbox form before opening the new form. PSF based forms do not exist after they are closed. If you are trying to use multiple data entry forms off a main form then you will have to save the contents and reapply it the next time the form is opened.
PowerShell only supports modal dialogs and Sapien always wraps a form in a function so it is removed from memory after the dialog is closed.
PowerShell only supports modal dialogs and Sapien always wraps a form in a function so it is removed from memory after the dialog is closed.
-
- Posts: 2
- Last visit: Thu Apr 29, 2021 9:37 am
Re: Forms closing and keep checekbox values
Hi, thanks for your answer.
Yes, I'm closing the form before opening the next one, as shown below:
I did this, because showing first and hiding after was not working for me, I don't know why, sincerely I have just two days with PowerShell Studio.
How could I save the contents and reapply? Do you have any docs I can read?
Yes, I'm closing the form before opening the next one, as shown below:
I did this, because showing first and hiding after was not working for me, I don't know why, sincerely I have just two days with PowerShell Studio.
Code: Select all
$btnNext_Click={
#TODO: Place custom script here
$frmMain.Hide()
Show-frmAuth_psf
}
Re: Forms closing and keep checekbox values
If this is a project then there are variables created for all child form controls so you could pass them as a parameters to the form and apply the contents/
A simpler way to reuse a form is to create a global hash and save the form object and name in the hash during the load of the form. THe second time you want to display the form use the saved form object and "ShowDIalog()" to re-display the saved form. All control contents will be still in the form. This should work with simple controls like checkboxes.
I have been waiting for Sapien to create a child form template that just creates the form and returns the form object which would make this a bit easier but the above method should work with few issues.
A simpler way to reuse a form is to create a global hash and save the form object and name in the hash during the load of the form. THe second time you want to display the form use the saved form object and "ShowDIalog()" to re-display the saved form. All control contents will be still in the form. This should work with simple controls like checkboxes.
I have been waiting for Sapien to create a child form template that just creates the form and returns the form object which would make this a bit easier but the above method should work with few issues.
Re: Forms closing and keep checekbox values
In case you haven't figured this out I had some time and knocked together a simple demo project.
Open the project and run it to see the child maintains the values when re-displayed.
The action code is in the "globals.ps1' file and the child is called like this:
Display-ChildForm Show-ChildForm_psf
Only one line needs to be added to the child form load event code:
$formsList.Add($formFunction,$this)
Open the project and run it to see the child maintains the values when re-displayed.
The action code is in the "globals.ps1' file and the child is called like this:
Display-ChildForm Show-ChildForm_psf
Only one line needs to be added to the child form load event code:
$formsList.Add($formFunction,$this)
- Attachments
-
- Demo-ReusableChild.zip
- (127.86 KiB) Downloaded 81 times