TextChanged event doesn't work.

Jack T picture Jack T · May 1, 2012 · Viewed 8.4k times · Source

I have a textbox in Form and i want to detect when the text has changed but the code I have found is giving me no joy.

I am probably missing something in the proporties or something you have to define before.

Here is my code:

private void tbxparkingTimesS1_TextChanged(Object sender, EventArgs e)
{
     MessageBox.Show("You are in the ToolStripItem.TextChanged event.");
}

Thanks for any help with this trivial problem.

Answer

Steve picture Steve · May 1, 2012

To wire the TextChanged event to a particular method inside your code do the following

  • Click on the TextBox inside your form
  • Open the properties windows (press F4 or menu View -> Property Window )
  • Select the event page (lightning icon)
  • Double click on the TextChanged property line
  • Insert your code inside the template build for you by Visual Studio