Jump to content
José Silve

Bloquear Letras e Caracteres Especiais

Recommended Posts

José Silve

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

Share this post


Link to post
Share on other sites
Mikev

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# 😍

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.