José Silve 0 Posted February 3, 2019 Report Share Posted February 3, 2019 Boa Noite, Gostaria de saber que código devo acrescentar ou alterar, para permitir bloquear as letras e caracteres especiais simultaneamente. Ou seja apenas permitir números! Pelo que eu pude analisar, seria programado no evento keypress e apenas tenho este código: if ((Char.IsLetter(e.KeyChar))) { e.Handled = true; } Aguardo Resposta, Atenciosamente José Silva Link to post Share on other sites
Mikev 1 Posted February 4, 2019 Report Share Posted February 4, 2019 Se só quiseres uma textbox que permita números é algo deste género: private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.')) { e.Handled = true; } C# 😍 Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now