How to make use of RegularExpressionValidators in case of Windows Forms ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Intro
    New Member
    • Apr 2012
    • 15

    #1

    How to make use of RegularExpressionValidators in case of Windows Forms ?

    I am currently using a Windows Application whcih contains many forms.
    OIn one of the forms, I want to validate :

    1.A TextBox(which will only accept digits 0-9)(the user won't be able top type any other except digits

    2. Another textbox which will accept only [a-z} and [A-Z ], No other key will be allowed to be types in the textbox.

    For the first requirement I used

    Code:
    System.Text.RegularExpressions.Regex myRegEx = new System.Text.RegularExpressions.Regex("^?{10}$");
    if (myRegEx.IsMatch(txtBox.text)) {
        //  Is ok
    }
    else {
        //  Is not ok
    }
    But unfurtunately this didn't work for me.
    kindly suggest a smarter way to validate.
    Your answers would be appreciated.

    Thanks in advance.
Working...