VALIDATION ON NUMERICUPDOWN CONTROL IN C#.NET

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
C# 
C#
 4498  View(s)
Ratings:
Rate this:
Hello Everyone,
I'm working with NumericUpDown Control in C#.Net and I want to user input limit validation in NumericUpDown control( Suppose that I want to user can input only three digit in numericupdown control). Let me know it as soon as possible. if possible then write down code too.

Thanks in advance!
  1. Arun Singh

    Post:68

    Points:476
    Re: Validation on NumericUpDown Control in C#.Net

    Hi Tanuj,
    You can use following line of code to validate user:

    private void numericUpDown1_KeyDown(object sender, KeyEventArgs e)
    {
    if (!(e.KeyData == Keys.Back || e.KeyData == Keys.Delete))
    if (numericUpDown1.Text.Length >= 3 || e.KeyValue == 109)
    {
    e.SuppressKeyPress = true;
    e.Handled = true;
    }
    }
    I hope it resolve your problem. Please marked as answer if it will resolve your problem.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!