控制C#中的文本输入只能是数字类型
privatevoid NumberAccpter(object sender, KeyPressEventArgs e)
{
int keyValue = (int)e.KeyChar;
if ((keyValue >=48&& keyValue <=57) || keyValue ==8|| keyValue ==46)
{
if (sender !=null&& sender is TextBox && keyValue ==46)
{
if (((TextBox)sender).Text.IndexOf(".") >=0)
e.Handled =true;
else
e.Handled =false;
}
else
e.Handled =false;
}
else
e.Handled =true;
}