Por lo visto lo necesitas para windows forms...
Yo lo haría así usando mejor el evento (KeyUp)
Cita: private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
int iKey = e.KeyValue;
if((iKey < 48) || (iKey > 57)) // para q solo sea numérico
{
string sCad = txtDni.Text; //guardo el texto y cadena original
int iLen = txtDni.Text.Length - 1; //obtengo el tamaño del texto actual
if (iLen!=0) {
txtDni.Text = sCad.Substring(0,iLen); //quito el último caracter ingresado
txtDni.SelectionStart = iLen; //posiciono el cursor
txtDni.SelectionLength = iLen;
}
}
Espero te sirva...