char number = e.KeyChar;
if (!Char.IsDigit(number))
{
e.Handled = true;
}
if (e.KeyChar <= 47 || e.KeyChar >= 58)
{
e.Handled = true;
}
public Window()
{
InitializeComponent();
this.textBox.PreviewTextInput += new TextCompositionEventHandler(textBox_PreviewTextInput);
}
void textBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
if (!Char.IsDigit(e.Text,0)) e.Handled = true;
}