MF Project

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 6 years and 11 months 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
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

MF Project

Post by localpct »

So I have a project
Form # 1 checks a few things, sets some variables
Form #2 prompts the user for stuff and has an Unlock button
This unlock button validates we have access to the drive and shows form #3

This is my code for the unlock button
  1. $buttonUnlock_Click= {
  2.     #TODO: Place custom script here
  3.    
  4.     #Manage-bde -unlock c: -recoverypassword $textbox3.text
  5.     if (Test-Path C:\Windows)
  6.     {
  7.         Show-MainForm_psf
  8.     }
  9.     $form2.Close()
  10.     $form2.Visible = $false
  11. }
What I'm having issues with is closing form2 cleanly, any help?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: MF Project

Post by jvierra »

$form2.Close()
Don't add any code after that line.

In PowerShell you cannot "switch" forms. You can only close the currently displayed form.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: MF Project

Post by localpct »

jvierra wrote:$form2.Close()
Don't add any code after that line.

In PowerShell you cannot "switch" forms. You can only close the currently displayed form.
While that works, the form is still displayed behind, if that's the best we can do. I'm okay with this.
This topic is 6 years and 11 months 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