0

I am using maskedTextBox.SelectAll() to highlight the text in the MaskedTextBox in the Enter and MouseDown events.

It works when I use the mouse, but I go to that textbox by pressing the Tab key, it does not work.

What am I missing here?

Jeff B
  • 8,572
  • 17
  • 61
  • 140
Bohn
  • 26,091
  • 61
  • 167
  • 254

1 Answers1

2

Have you tried the GotFocus event?

When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:

It then goes on to list the events that are fired. It looks like this fires when the mouse is used so you might only need this handler.

ChrisF
  • 134,786
  • 31
  • 255
  • 325
  • Chris! I wanted to use GotFocus but could not Find it in the list of the events in the properties window... where is it? – Bohn Jul 07 '10 at 18:59
  • @BDotA - I found it via the MSDN - it's an event on `Control` so it might not appear. Try adding it manually. – ChrisF Jul 07 '10 at 19:01
  • Ok, thanks, that explains why it is not listed in the properties window.. i will try it. – Bohn Jul 07 '10 at 19:02