C# (Csharp): TextBox'a Sadece SayıGirme



          Merhaba arkadaşlar. Bir textbox kullanıyorsunuz ve içerisine sadece sayı girilmesini istiyorsanız yapmanız gereken textbox'ın KeyPress ine aşağıdaki kodları yazmaktır


        private void txt_Sayi_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar)
            {
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                case '0':
                case '\b':
                    break;

                default:
                    e.Handled = true;
                    break;
            }
        }


          Kolay gelsin.

Yorumlar