CTRL+A not working for textboxes

Posted on 2008-10-07
Last Modified: 2013-12-17
I've trying creating brand new projects and adding a single textbox and even then the CTRL+A for select all doesn't work, it just makes the beep noise.

Now the confusing part is I actually have one of my open source projects that actually works with CTRL+A and if I copy its textboxes out they'll have it working in other programs, but if I modify them then it fails to work.

I have one program with the CTRL+A working, and it doesn't have any differences in the actual textbox, and if it gets copied out to another form/program it'll be working for that specific textbox in that program as well.

Also, I'm using Visual C# Express 2008.
Question by:krusho
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 30

Expert Comment

ID: 22666157
Just write an event handler for key_down event and put the following code into there:

            if(e.Modifiers == Keys.Control && (e.KeyCode==Keys.A ||e.KeyCode==Keys.A))

Author Comment

ID: 22670788
I was hoping to avoid doing it for each individual textbox, since the one program that has it working doesn't have any keydown events being handled.
LVL 30

Expert Comment

ID: 22673090
It means they use magic :)

Check if such a handler was attached in some other way and was not created with designer.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 22673819
The confusing part is that the program that has it's 2 textboxes working is the same as the default new project I make. If I copy one of those textboxes into the new program then that box will work until I start modifying it.

Accepted Solution

krusho earned 0 total points
ID: 22673981
I figured out the solution, as to one one appears to magically work. This is rather dumb though and I don't know why Microsoft would make this matter.

this.textBox1.Multiline = false; // this can use CTRL+A
this.textBox1.Multiline = true; // this cannot use CTRL+A

The reason I was being confused is because I failed to realize that working textBox was not multiline, and that the other textBox on that form was actually a RichTextBox

this.richTextBox1.Multiline = false; // this can use CTRL+A
this.richTextBox1.Multiline = true; // this can use CTRL+A

Author Comment

ID: 22674043
Also, this is another work around since you may still want to use a multiline textbox:

namespace MyTextBoxDemo
    public class MyTextBox : System.Windows.Forms.TextBox
        protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
            if (e.Control && (e.KeyCode == System.Windows.Forms.Keys.A))
                e.SuppressKeyPress = true;
                e.Handled = true;

just override the textbox OnKeyDown

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question