遮蔽文字框非法輸入
阿新 • • 發佈:2018-12-18
遮蔽文字框非法輸入
protected override void OnTextChanged(TextChangedEventArgs e)
{
TextChange[] change = new TextChange[e.Changes.Count];
e.Changes.CopyTo(change, 0);
int offset = change[0].Offset;
if (change[0].AddedLength > 0)
{
int num = 0;
if (!int.TryParse(Text, out num))
{
Text = Text.Remove(offset, change[0].AddedLength);
Select(offset, 0);
}
}
}