Problem with handling event in checkedlistbox control

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
josh.perkins
Posts: 4
Joined: Mon Mar 18, 2013 8:52 am

Problem with handling event in checkedlistbox control

Post by josh.perkins »

Not sure how to properly handle this in PowerShell studio. I have a checkedlistbox and want to display a textbox when a specific item in the checkedlistbox is checked. The problem I am running into is that the checkedlistbox (itemcheck and click) event doesn't see the check value until after the event fires.

Any help would be great.

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

Re: Problem with handling event in checkedlistbox control

Post by davidc »

FYI, I moved the post to the GUI forum.

You need to use the ItemCheck event and use the new value property:
PowerShell Code
Double-click the code block to select all.
$checkedlistbox1_ItemCheck=[System.Windows.Forms.ItemCheckEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.ItemCheckEventArgs]
	#TODO: Place custom script here
	if($_.NewValue -eq 'Checked')
	{
		
	}
}
David
David
SAPIEN Technologies, Inc.

Locked