How to apply numeric validation in c#.Net

This code user can not enter any letters and symbol in textbox  user anter only digits.

=> Create project.
=> take textbox from toolbox
=> select textbox and goto propeties window and click on event tab.
=> double click on KeyPress event.
=> write following code

CODE:


 //this code is for when user enter any digit then it alllow to enter but when user enter any letters then it does not alloe to enter letters in textbox..
       private void txtSn_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
            {
                e.Handled=true;
            }
        }

--
/\/ir@\/  <(.'.)>

Comments

Popular posts from this blog

How to use serial.write() in Arduino.

How to make and use web service in Microsoft Dynamics Navision.

How to Generate random rows in dataset using c#.net