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.
Locked
User avatar
R1Johnny
Posts: 37
Joined: Thu Aug 18, 2011 12:22 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
Joined: Thu Aug 18, 2011 12:22 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: 14573
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Contact:

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
Joined: Thu Aug 18, 2011 12:22 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: 14573
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Contact:

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/

Locked