C# / Filter input of a textbox and display notification balloon
- by asmo
I'm wondering how to filter the input of a .NET textbox.
I already know that I could listen for the KeyDown event and intercept the key, but that won't filter pasted strings by a right-click menu or a CTRL+V.
I also don't wan't to completely disable the possibility of pasting of characters in the textbox. The paste action should be cancelled whenever it contains one or more invalid characters.
Finally, I'd like to display a notification balloon whenever invalid characters are either entered or pasted.
µTorrent already has this exact behavior:
How can I achieve this functionality in C# ?