Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 722
user3289840 Avatar asked Feb 13 '14 21:02

user3289840


People also ask

What is TextChanged?

The TextChanged event is raised when the content of the text box changes between posts to the server. The event is only raised if the text is changed by the user; the event is not raised if the text is changed programmatically.

Which event is generated when TextBox text is changed?

The event handler is called whenever the contents of the TextBox control are changed, either by a user or programmatically. This event fires when the TextBox control is created and initially populated with text.


1 Answers

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

like image 170
Michael Oliver Avatar answered Sep 22 '22 03:09

Michael Oliver