0

I have a simple TextBox called MsgBox1 and I have changed the trigger from LostFocus to ProperyChanged.

When I modify the text (i.e. MsgBox1.Text = "Some Text") execution branches to the event handler.

So far, so good.

Now, what do I put in the empty event handler to tell it to actually update MsgBox1.Text?

Hours of searching yields less than helpful results like:

    {
     // Do Something
    }

Edit: Thanks, It was stupidity on my part. The methods don't run in parallel while tracing. If I run rather than trace everything works as it should. Thanks again.

2
  • 4
    It will update the value, the event is telling you it happened. In there, you can react to the fact that the value changed. Commented Aug 5, 2014 at 20:53
  • The event is triggered when the text changes, therefore the text in the TextBox has already changed. Commented Aug 5, 2014 at 21:16

1 Answer 1

1

As stated in the comments there is no need to update anything. The event fires when the textChange event occurs.

you can test this by using the following code :

private void textBox1_TextChanged(object sender, EventArgs e)
{
    var currentTextValue = this.textBox1.Text;
    var currentTextValueFromObject = (sender as TextBox).Text;
}

both vars yield the same result. One grabs the object from the event handler while the other grabs it directly from the form.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Paul, That makes sense and I can see the contents of the variable change in the trace window. The actual textbox on the form, however, remains unchanged. Knowing that it should be updating and it's just some stupid newbee syntax error is a huge help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.