I am currently working on a WinForms project and have a few text boxes on the form which are used to take user input. Based on the values the user enters, the values for other fields on the form are calculated. Consequently, I am confused which of the two event handlers I should use to perform the calculations: textbox_Leave or textbox_TextChanged?
Since textbox_TextChanged is fired every time the user changes even a character in the textbox, I feel it is very expensive in terms of processor usage, isn’t it? On the other hand, textbox_Leave is executed only after the user exits from the text box. However, the TextChanged event does give a better more responsive experience to the user. But is this experience worth the extra processing hit that we are taking? Will my project be able to function properly on older systems with slower processors if I use TextChanged?
The trick here is not to process if you don’t have to, I usually schedule the “heavy duty stuff”, and run it after a while if the TextBox has not been changed again. Something like this: