How to restrict users to input only numbers in TextBox control in windows form C#?

Share Post
  •  
  •  
  •  
  • 2
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    2
    Shares

Please Subscribe Youtube| Like Facebook | Follow Twitter

In this tip we will write a code under KeyPress Event of TextBox control that will restrict user to type only numeric value in TextBocx control in windows form C#.

private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
     if (!Char.IsDigit(e.KeyChar))
          e.Handled = true;
}

Please Subscribe Youtube| Like Facebook | Follow Twitter


Share Post
  •  
  •  
  •  
  • 2
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    2
    Shares

Leave a Reply

Your email address will not be published. Required fields are marked *