Friday, 3 April 2015

Allow Only Enter Numbers or Digits in Textbox Using in C# Window Application

Allow Only Enter Numbers or Digits  in Textbox


Textbox Only Enter Allow Number Values Accepts  Character Values Not Acepted in C# Window Application.

                              DEMO



                                  C# CODING

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class MobileNumber : Form
    {
        public MobileNumber()
        {
            InitializeComponent();
        }

        private void txtMobileNumber_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (char.IsDigit(e.KeyChar) || char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }
    }
}



















0 comments:

Post a Comment