Select All (ctrl+A) does not work in TextBox?

G

Guest

I notice that Select All (Ctrl+A) does not work in a textbox on a form. Is
there anything I am missing to set? The KeyPreview on the form is off.

Ctrl+C and Ctrl+V works.
 
J

Jeff Gaines

I notice that Select All (Ctrl+A) does not work in a textbox on a form. Is
there anything I am missing to set? The KeyPreview on the form is off.

Ctrl+C and Ctrl+V works.

I think you have to use Ctrl+Home then Ctrl + Shift + End to select text
in a TextBox, I have never got Ctrl+A to work.
 
G

Guest

I guess that should work.

But, I think this behavior should have been there by default - its normal
windows behavior is'nt it? Right click popup menu shows the "Select All" in
the. It would be nice to have it in.

Thanks
 
L

lydonbergin

I notice that Select All (Ctrl+A) does not work in a textbox on a form. Is
there anything I am missing to set? The KeyPreview on the form is off.

Ctrl+C and Ctrl+V works.

I was wondering why this wasn't build into the TextBox control myself,
but anyway, this should work:

Create this handler and hook it into all of your TextBox.KeyPress
events

private void SelectAll(object sender, KeyPressEventArgs e)
{
if ((System.Windows.Forms.Control.ModifierKeys ==
Keys.Control) && (e.KeyChar == (char)Keys.A))
((TextBox)sender).SelectAll();
}

Not sure this is the best way to accomplish what you want but it
should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top