Click Event with Parameters

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 4 years and 3 days 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
Bender2010
Posts: 6
Last visit: Mon Jan 29, 2024 1:29 am

Click Event with Parameters

Post by Bender2010 »

Hello together,

I have some buttons with a click event. The function behind the Click event have also a specific parameters, which is necessary to working. On my button, I could definde the function for the Click event, but where I can define the parameters for the funktion?
Event.PNG
Event.PNG (5.81 KiB) Viewed 1168 times

Code: Select all

$buttonRev_Click={
	Param (
		[int]$RevisionNum
	)
	$tabpageLocations.Controls["textboxRev$($RevisionNum)"].Text = [int]($tabpageLocations.Controls["textboxRev$($RevisionNum)"].Text) + 1
}
- PowerShell Studio 5.7.173
- 64 bit version
- OS 64 bit.

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

Re: Click Event with Parameters

Post by jvierra »

You cannot use parameters on an event script block. The system calls that event and passes its own parameters. Yours will be over-written or ignored.

In Windows we get values in an event from the controls that contain the values or from script scoped variables.
User avatar
Bender2010
Posts: 6
Last visit: Mon Jan 29, 2024 1:29 am

Re: Click Event with Parameters

Post by Bender2010 »

Okay, thank you for your information. I searching then for a another solution.

Best regards
This topic is 4 years and 3 days 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