CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #2
    Join Date
    Jul 2005
    Location
    Louisville, KY
    Posts
    201

    Re: Restrict text input

    Hello Nmohammed, the following code will allow only a-z and A-Z characters to be entered into the textbox. You'll need to create the KeyDown event for the textboxes, in order to utilize the code. In the future, I'd also like to suggest, for readability, to use [ code ] tags, on your code. Enjoy.

    Code:
    private void txtTextbox1_KeyDown(object sender, KeyEventArgs e)
    {
        if ((e.Key < Key.A) || (e.Key > Key.Z))
           e.Handled = true;
    }
    Regards,
    Quinn

    If this post resolves your question, please make sure to flag post as resolved and please rate up this post. Thanks.
    Last edited by QuinnJohns; October 16th, 2011 at 03:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured