Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

How do make the texbox accept only numerics, del key and backspace?

$
0
0

hi friends,

is there away to make a textbox accept only numeric, del key and backspace key?

I used the following code but it doesn't work:

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ( char.IsDigit(e.KeyChar) == true || e.KeyChar == Convert.ToChar(Keys.Back) || e.KeyChar == Convert.ToChar(Keys.Delete) )
            {
                e.Handled = true;
            }
        }

thanks

I use Visual studio 2010 professional and SQL server 2008 developer edition!


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>