C# WinForm textbox 全选

原地址:忘了

textBox1.KeyPress += anyTextBox_KeyPress;
private void anyTextBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
    if (e.KeyChar == '\x1')
    {
        ((TextBox)sender).SelectAll();
        e.Handled = true;
    }
}

 

posted @ 2018-08-17 16:43  古兴越  阅读(1148)  评论(0)    收藏  举报