Friday, July 23, 2010

Input only Number in TextBox in C#

IsDigit


IsHighSurrogate

IsLetter

IsLetterOrDigit

IsLower

IsLowSurrogate

IsNumber

IsPunctuation

IsSeparator

IsSurrogate

IsSurrogatePair

IsSymbol

IsUpper

IsWhiteSpace



private void textBox1_KeyPress(object sender, KeyPressEventArgs e)

{

if (Char.IsDigit(e.KeyChar) )

{ MessageBox.Show("Bad Input");

e.Handled = true; ;

}}

// It will Input Only Digit in TextBox
            if ((e.KeyChar < '0') || (e.KeyChar > '9'))
            {
                e.Handled = true;
            }
          
            // It will Input Only Alphabet and Digit in TextBox nothing else
            if (!Char.IsLetterOrDigit(e.KeyChar))
            {
                MessageBox.Show("Bad Input");
                e.Handled = true; ;
            }

No comments:

Post a Comment

Mat Table Angular

Mat Table in Angular Mat table is used to display data . its a material designed styled data-table . For using Material Table MatTableMo...