Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 311

PowerShell Studio • FormClosingEventHandler does not work

$
0
0
Product, version and build: PowerShell Studio 2023 (64 Bit) v5.8.221
Operating system: Windows 11 Enterprise 22H2
PowerShell version(s): 5.1.22621.2506

Hi,

I would like to control the closing of my form and tried to follow your article about Form Control (https://info.sapien.com/index.php/guis/ ... FuZGxlciJd)
and I’ve inserted the line:
$MainForm_FormClosing = [System.Windows.Forms.FormClosingEventHandler]{$_.Cancel = $true}

but I can still close the form like normal.

After some investigation I found that the line
$MainForm.add_FormClosing($MainForm_FormClosing)
in the #region Generated Form Code
and
$MainForm.remove_FormClosing($MainForm_FormClosing)
in the $Form_Cleanup_FormClosed code-block
….was missing

It seems that these lines do not get created when exporting or running the script

The ”MainForm_FormClosing” event does show in the event list (se att. FormEvents.png)

Am I doing this wrong :? ?

Thanks in advance
Kenneth Jensen
FormEvents.png

Statistics: Posted by JN-SWD — Thu Feb 15, 2024 6:55 am — Replies 1 — Views 7



Viewing all articles
Browse latest Browse all 311

Trending Articles