textBox2.Focus();
textBox2.SelectionStart = 0;
textBox2.SelectionLength = textBox2.Text.Length;
这是找到的代码, 自己要用做函数,就写了一下
private void button2_Click(object sender, EventArgs e)
{
SelectAll(textBox2);
}
public static TextBox SelectAll(TextBox TB)
{
TB.Focus();
TB.SelectionStart = 0;
TB.SelectionLength = TB.Text.Length;
return TB;
}