过滤用户输入内容
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
//屏蔽中文输入和非法字符粘贴输入
TextBox textBox = sender as TextBox;
TextChange[] change = new TextChange[e.Changes.Count];
e.Changes.CopyTo(change, 0);
int offset = change[0].Offset;
if (change[0].AddedLength > 0)
{
float num = 0;
if (!float.TryParse(textBox.Text, out num))
{
textBox.Text = schemeTime.ToString();
}
}
}
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
TextBox textBox = sender as TextBox;
float.TryParse(textBox.Text, out schemeTime);
}