Home > DeveloperSection > Forums > C# Basics - TextBox event handler
Chintoo Semi

Total Post:135

Posted on    August-14-2014 4:59 AM

 C# C# 

 1 Reply(s)
 1205  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


Pravesh Singh

Total Post:412

Posted on    August-14-2014 5:22 AM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick