Tabpage events not raised

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.
Locked
User avatar
stevendes
Posts: 4
Joined: Sun Mar 03, 2013 12:44 pm

Tabpage events not raised

Post by stevendes » Wed Apr 03, 2013 9:24 am

I've created a tabcontrol with several tabpages in it.
Now I want to catch the events that are raised whenever a tabpage is left.
PowerShell Code
Double-click the code block to select all.
$tabpage1_Leave={
	#TODO: Place custom script here
	
}
If I set a breakpoint it is only being hit when the application is started, but if I change focus of the tabpages it is no longer raised.

If I create a similar project within Visual Studio, proper events are raised.

I am stuck at the moment, am I missing something?

User avatar
davidc
Posts: 5839
Joined: Thu Aug 18, 2011 4:56 am

Re: Tabpage events not raised

Post by davidc » Wed Apr 03, 2013 9:46 am

The Leave event fires when the TabControl loses focus not when a tabpage changes.

You will need to use the Deselecting or Deselected event instead.


FYI I moved the post to the PowerShell GUIs Forum.

David
David
SAPIEN Technologies, Inc.

User avatar
stevendes
Posts: 4
Joined: Sun Mar 03, 2013 12:44 pm

Re: Tabpage events not raised

Post by stevendes » Thu Apr 04, 2013 1:13 am

Thx David, this seems to work.

Locked