小智 7
您可以处理PreviewTextInput事件:
private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
// Filter out non-digit text input
foreach (char c in e.Text)
if (!Char.IsDigit(c))
{
e.Handled = true;
break;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8498 次 |
| 最近记录: |