检查文本框的keydown事件并执行
// If escape is presses, then close the window.
if( Key.Escape == e.Key )
{
this.Close();
}
// Allow alphanumeric and space.
if( e.Key >= Key.D0 && e.Key <= Key.D9 ||
e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9 ||
e.Key >= Key.A && e.Key <= Key.Z ||
e.Key == Key.Space )
{
e.Handled = false;
}
else
{
e.Handled = true;
}
// If tab is presses, then the focus must go to the
// next control.
if( e.Key == Key.Tab )
{
e.Handled = false;
}
Run Code Online (Sandbox Code Playgroud)
希望这会有所帮助......
| 归档时间: |
|
| 查看次数: |
6336 次 |
| 最近记录: |