click close command not working

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 11 months and 4 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
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

click close command not working

Post by mqh77777 »

Product: PowerShell Studio 2023 (64 Bit)
Build: v5.8.217
OS: Windows 10 Pro (64 Bit)
Build: v10.0.22621.0


Hello, I have a brand new form called $formCommands
I added 1 button called Close. For the code behind this button I have this:
$Close_Click = {$formCommands.Close()}

I compile and run my form. I press the close button and nothing happens. Is my close_click command inaccurate?
Thanks.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: click close command not working

Post by brittneyr »

[Topic moved by moderator to PowerShell GUIs forum]
Brittney
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: click close command not working

Post by jvierra »

Normally that would close the form although the form may be blocked in another event. There is not enough information in your post to say why it won't close.

What do you mean by "compile" scripts are not compileable. Are you using PowerShell Studio or some other utility.
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: click close command not working

Post by mqh77777 »

Hello. Yes I am using PowerShell Studio.

Product: PowerShell Studio 2023 (64 Bit)
Build: v5.8.217
OS: Windows 10 Pro (64 Bit)
Build: v10.0.22621.0



Create new form.
Name form.
add 1 button to form called Cancel.
Choose the following settings. SAPIEN PowerShell V5 Host (Windows Forms)
compile form into an .EXE
run .EXE
press the close button. Nothing happens. The form will not close.

Thank you.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: click close command not working

Post by jvierra »

You seem to have failed to add the close code to the button click event.
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: click close command not working

Post by mqh77777 »

this is the exact code I have

$buttonClose_Click={
$Close_Click = {$formCommands.Close()}
}

is this incorrect?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: click close command not working

Post by jvierra »

No.
  1. $buttonClose_Click={
  2.      $formCommands.Close()
  3. }
This topic is 11 months and 4 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