Textbox input as value

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 4 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
rwlib3
Posts: 11
Last visit: Thu May 02, 2019 9:06 am

Textbox input as value

Post by rwlib3 »

This may be a stupid question, but I'm unable to find an answer via search. I'm probably just missing a piece to this puzzle.

If I use a textbox for manual user input, can that input value be used as a variable in the cmdlet run on a button push?

For example: user enters a SAMACCOUNTNAME in textbox1 and clicks button1.

textbox1_TextChanged={
#TODO:
}

$button1_Click={
#TODO:
Get-mailbox -identity $textbox1_TextChanged.text
}

Thanks in advance for any assistance on my ignorance! :D
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Textbox input as value

Post by jvierra »

PowerShell Code
Double-click the code block to select all.
$button1_Click={
 #TODO:
 Get-mailbox -identity $textbox1.text
}
Read this sites blog on how to use forms.
User avatar
rwlib3
Posts: 11
Last visit: Thu May 02, 2019 9:06 am

Re: Textbox input as value

Post by rwlib3 »

thank you! I knew I was just missing something. I was using the wrong variable.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Textbox input as value

Post by jvierra »

You were very close.

Definitely check out the blog articles. They are very useful:

http://www.sapien.com/blog/topics/user- ... istrators/

They are written by the developers of PowerShell Studio. They are very good. Even Microsoft has given them "kudos" for the tool and the info - maybe even CUDOS.
This topic is 10 years and 4 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