Search code examples
c#event-handlingtextchanged

What is the difference between TextUpdate and TextChanged Event?


for each control there are a lot of events, two are very similar such as Text Update and Text Changed, whis is the difference?


Solution

  • Here's my take on things, with sources from MSDN. I've used TextBox and ComboBox for my examples, however I'm fairly sure the logic generalizes.

    TextUpdate:

    Occurs when the control has formatted the text, but before the text is displayed. Use the TextUpdate event to validate the text before it is actually shown.

    An example would be if a ComboBox is being populated from some datasource, and the data changes. This could trigger the TextUpdate event to allow for validation (or anything else).

    http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.textupdate(v=vs.110).aspx

    TextChanged:

    Occurs when content changes in the text box. User input or setting the Text property to a new value raises the TextChanged event.

    I think that quotation covers the example usage.

    http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.textchanged(v=vs.95).aspx