I want to cancel out key press event when my textarea field gets n number of characters from user. At that point i dont want user to enter any more characters. What to do?
In web pages, NobleCount is one possibility. Seems to be the most robust of the jQuery plugin solutions. It will give your user a count of the number of characters remaining, Twitter-style.
Interactive character limit for textarea using Jquery http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/
In Winforms, you would set Handled in the KeyPressEventArgs to true to cancel the KeyPress event. This keeps the control from processing the key press.
Note: Some controls will process certain key strokes on KeyDown. For example, RichTextBox processes the Enter key before KeyPress is called. In such cases, you cannot cancel the KeyPress event, and must cancel the key stroke from KeyDown instead.