DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Ctrl-A Shortcut To Select All Text (Windows.Forms.TextBox)

07.23.2008
| 11091 views |
  • submit to reddit
        Set this event handler for your textbox to enable Ctrl-A shortcut and select all text:


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