TextBox.SelectAll() does not work with TAB

杀马特。学长 韩版系。学妹 提交于 2019-12-13 05:23:01

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3197870/textbox-selectall-does-not-work-with-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!