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.
This topic is 10 years and 9 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
josh.perkins
Posts: 4
Last visit: Mon Jun 26, 2023 2:46 pm

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
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

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.
This topic is 10 years and 9 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