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

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
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
 
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.
 
Back
Top