Insert Only Numeric Value In TextBox(Windows Application)
This code demonstrates how to Insert Only Numeric Value In TextBox(Windows Application)
Insert Only Numeric Value In TextBox(Windows Application)
private bool nonnumberenter = false;
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
nonnumberenter = false;
if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
{
if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
{
if (e.KeyCode != Keys.Back)
{
nonnumberenter = true;
}
}
}
if (Control.ModifierKeys == Keys.Shift)
{
nonnumberenter = true;
}
}
Hi Mr.hardik,
Very usefull info..
Thanks for sharing with all of us.
regards,
harshitha