KeyDown-Event

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 5 years and 1 month 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
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

KeyDown-Event

Post by bhnuser »

Hello everyone,

at the time i build a new GUI for some employees. They can search a AD-User and can edit him.
Here are the question/problem: When i create a KeyDown-Event in a textbox, it works fine in the PowerShell Studio. But if build an executable file it wont work.
How i tried it:

Code: Select all

$textboxUsername_KeyDown=[System.Windows.Forms.KeyEventHandler]{
	if ($_.KeyCode -eq 'Enter')
	{
		#$buttonUserSearch_Click.Invoke()
		$buttonUserSearch_Click.PerformClick()
	}
}
$buttonUserSearch_Click : There is the algorithm to get the AD-User information

Does anyone have a solution?

Best regards
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: KeyDown-Event

Post by davidc »

Without the whole script is hard to determine the problem. Try placing a Message Box in the button's click event. That way you can tell if the click event is fired or not.

Use the msgbox snippet.
David
SAPIEN Technologies, Inc.
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

Re: KeyDown-Event

Post by bhnuser »

I tried it with a MessageBox. As if from nowhere it works without any reason.

I will continue to monitor it.
This topic is 5 years and 1 month 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