المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How Do I Handle A Textbox Change Correctly?



C# Programming
05-21-2010, 06:41 AM
My code for calculating fluid flows in a pipe or channel is working nicely now, except for the last step. I use a textbox for user input of a selected slope, and a TextChanged event to perform the final calculation. But the moment I enter one character, my event handler is called. I thought it would wait until I tabbed away from the field, or until I pressed Enter to process the change, but apparently not. If I enter, for example, 1.234, it works fine (except that the answer is an overflow in this equation), but if I enter a decimal point, as in .016, the instant I enter the point I generate an exception - invalid format.

What am I doing wrong here? Is there another event I should use? Can I fix this one?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"