开发者

C# / Filter input of a textbox and display notification balloon

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:

C# / Filter input of a textbox and display notification balloon

How can I achieve this functionality in C# ?


TextChanged event - Seems like a good call.

You can spawn your own baloon or ToolTip on any control you want to show a detailed feedback to the user


It seems like a combination of KeyPress, TextChanged, Validating, and Validated events should work for your purposes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜