The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

    • RT @joslat: Hi .NET community, I just posted a new blog on Implementing a GraphQL Client in Blazor with StrawberryShake & HotChocolate - yo… 52 minutes ago
    • @shanselman I am not surprised. 1 hour ago
    • Ondanks zeker 6 keer "retour afzender" blijft @Amref_NL maandelijks post sturen. Pennen gaan na de crisis naar @carmenverheul. 1 hour ago
    • RT @marcdehond: Nu live vanuit het Witte Huis, zeker 15 politici die zich niks aantrekken van social distancing. Wat een voorbeeld voor de… 1 hour ago
    • RT @jaredpar: There is nothing I appreciate more than bugs that have minimal repros attached to them. 1 hour ago
  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,866 other followers

Archive for December 4th, 2012

.NET/C#/WinForms: small code snippet to enable Ctrl-A for select all in a single/multi-line TextBox

Posted by jpluimers on 2012/12/04

WinForms does not automatically enable Ctrl-A as “Select All” action.

The below code snippet works when you bind it to the KeyDown event of a TextBox (actually the event is on Control).

The e.SuppressKeyPress = true suppresses the bell sound in a multiline TextBox, as e.Handled = true won’t.

        private void textBox_KeyDown_HandleCtrlAToSelectAllText(object sender, KeyEventArgs e)
            TextBox textBox = sender as TextBox;
            if (null != textBox)
                if (e.Control && e.KeyCode == Keys.A)
                    e.SuppressKeyPress = true;


Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »

%d bloggers like this: