Immediate change to box contents based on input to other tex

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 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
R1Johnny
Posts: 37
Last visit: Mon Dec 12, 2022 7:15 am

Immediate change to box contents based on input to other tex

Post by R1Johnny »

Good evening.

Please consider 2 textboxes. One is for integer #1, the second is for integer #2.
Based on the contents of these boxes I'd like the "Total" textbox to be computed immediately when the focus changes away from either the integer 1 or integer 2 textboxes.

Example: A user types "3" in input box 1, and types "2" in input box 2.
I'd like the result to be displayed immediately when the user clicks anywhere else on the screen.

What type of box should "Total" be and how would I go about scripting the response that I desire?

Thanks very much.
Regards,
John
User avatar
R1Johnny
Posts: 37
Last visit: Mon Dec 12, 2022 7:15 am

Re: Immediate change to box contents based on input to other

Post by R1Johnny »

Upon further reflection, I'd like to ask the question a bit differently.
A user inputs "3" to integer textbox #1. A "3" appears immediately in the "Total" box

The user then inputs "2" into integer textbox #2. As soon as the 2 is input, the value of "Total" changes automatically and immediately to 5.

Extending the example, the user then changes integer textbox #1 by entering "1". The value of the "Total" box changes immediately to 3.

Can you please advise on the type of box for "Total" and the method to invoke the immediate update?

Thanks again.

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

Re: Immediate change to box contents based on input to other

Post by jvierra »

You have to write the code to do that. It requires using arithmetic and adding the values. There is no magic method. Just simple coding and assignment.

2 + 1 = 3

$tb3.Text = [int]$tb1.Text + [int]$tb2.Txt

Start here: http://www.sapien.com/blog/topics/user- ... istrators/
User avatar
R1Johnny
Posts: 37
Last visit: Mon Dec 12, 2022 7:15 am

Re: Immediate change to box contents based on input to other

Post by R1Johnny »

Good afternoon,
Understood about the math. That's a given.
I was just wondering how to make the changes immediate when the user inputs the integers.
How do I make $tp3.text update immediately without any button clicks?

Thanks again.

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

Re: Immediate change to box contents based on input to other

Post by jvierra »

Pick and event and use it to set the other boxes.

Read the blog on GUI design for administrators to learn how Forms work.

http://www.sapien.com/blog/topics/user- ... istrators/
This topic is 10 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