C# Basics - TextBox event handler

Total Post:135

 1622  View(s)
Rate this:

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
  1. Post:412

    Re: C# Basics - TextBox event handler

    Hi Chintoo, 

    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.

      Modified On Apr-04-2018 05:31:27 AM



Enter your email address here always to be updated. We promise not to spam!