May 28, 2016

Text Box Should Only Accept Numeric Values


 Hi Friends,

Today I will tell you how a Text Box Will only accept Numeric Values

private void txtPayment_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
        }

Hope that this simple code will make your work done.

Regards
Sudhir Singh
Software Developer at Fadsan Technologies