bool[] bIsNum;
string strTemp = string.Empty;
private void textBox1_TextChanged(object sender, EventArgs e)
{
bIsNum = new bool[textBox1.Text.Length];
for (int i = 0; i < bIsNum.Length; i++)
{
bIsNum[i] = false;
}
int n = 0;
foreach (char c in textBox1.Text)
{
for (int i = 0; i <= 9; i++)
{
if (c.ToString() == i.ToString())
{
bIsNum[n] = true;
break;
}
}
n++;
}
foreach (bool b in bIsNum)
{
if (b == false)
{
textBox1.Text = strTemp;
break;
}
}
strTemp = textBox1.Text;
textBox1.SelectionStart = textBox1.Text.Length;
}