Ish
Ish

Reputation: 671

Update on Change

I have a textbox(1) wich automaticly calculates and displays the input after a textbox(2) is updated. Textbox(1) is set to enabled = false so the user can not input any values as it updates automatically.

I want to display the number in Textbox(1) after it has changed/updated. I have tried using the AfterUpdate property for Textbox(1) but does not work because the user is not physically updating the value.

Is there any way to detect a change when the number changes in the textbox and store the number in another textbox?

Upvotes: 0

Views: 3059

Answers (2)

Christian Specht
Christian Specht

Reputation: 36431

As already said by others, if the user enters stuff into Textbox2 and you want to display that in Textbox1, then you have to use the events of Textbox2, not Textbox1!

The easiest way would be to use the AfterUpdate event of Textbox2.
Example:

Private Sub Textbox2_AfterUpdate()
    Me.Textbox1 = "Text from second textbox: " & Me.Textbox2
End Sub

Upvotes: 2

Jeff Robert Dagala
Jeff Robert Dagala

Reputation: 633

You can either use the OnLostFocus (http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onlostfocus.aspx) to tell when the user's focus leaves the textbox.

Otherwise you can use OnKeyPress (http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onkeypress.aspx) and a timer to tell how long since the last keystroke.

Upvotes: 0

Related Questions