Home  >  Article  >  php教程  >  C#TextBoxCtrl+A全选

C#TextBoxCtrl+A全选

WBOY
WBOYOriginal
2016-07-06 13:30:261631browse

在TextBox控件中使用快捷键,一般要求按下快捷键立刻产生效果,KeyUp事件显然不符合我们的要求,而KeyPRess事件中不支持使用组合件,所以我们选用KeyDown事件,具体代码实现如下: private void tBBefore_KeyDown( object sender, KeyEventArgs e){ if (e.Co

在TextBox控件中使用快捷键,一般要求按下快捷键立刻产生效果,KeyUp事件显然不符合我们的要求,而KeyPRess事件中不支持使用组合件,所以我们选用KeyDown事件,具体代码实现如下:

private void tBBefore_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.KeyCode == Keys.A)
    {
        ((TextBox)sender).SelectAll();
    }
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn