RE:como hacer que un textbox me acepte solo numero
Publicado por
Raul N (1 intervención) el 27/10/2008 07:07:09
Hola este codigo solo acepta numeros, tienes que usar el metodo KeyPress de tu textBox
y aparte cada que das enter y no este vacio el txt ejecuta lo que le pidas
private void txtPagina_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar))
{
e.Handled = true;
if (e.KeyChar == 13 && txtPagina.Text != string.Empty)
{
txtPagina.Text = string.Empty;
txtPagina.Focus();
}
}
}