What is your question? Are you trying to do input validation on a textbox? If so then that is done in Winforms using the Validating event. That event is triggered when a control loses focus and the control gaining focus has CausesValidation
set to true (which is the default) as discussed here.
Note that you should not be calling the event handlers directly in your code. This is non-standard, especially since you aren't handling the validating event correctly in your code. If you need to validate a control then tell the parent control/form to validate the children again. This is a limitation of Winforms validation because you cannot change focus while inside the event you're handling and winforms works based upon focus change.
Note that a better approach, instead of handling key up, might be to use the TextChanged
event. This is raised when the text changes for any reason. The downside is that it gets called for every character typed. The issue with your KeyUp
handler is that it is only handling 1 possible way to paste data into a textbox. There are other ways and your code isn't handling such as Shift+Insert (IIRC) and mouse context menu.