TextBox.SelectAll() 不适用于 TAB

发布于 2024-09-08 21:18:46 字数 199 浏览 2 评论 0原文

我使用 maskedTextBox.SelectAll()EnterMouseDown 事件中突出显示 MaskedTextBox 中的文本。

当我使用鼠标时它可以工作,但是我通过按 Tab 键转到该文本框,它不起作用。

我在这里缺少什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2024-09-15 21:18:46

您是否尝试过 GotFocus 事件?

当您使用键盘(TAB、SHIFT+TAB 等)、调用 Select 或 SelectNextControl 方法或将 ContainerControl.ActiveControl 属性设置为当前窗体来更改焦点时,焦点事件会在以下顺序:

然后它继续列出被触发的事件。看起来当使用鼠标时会触发此事件,因此您可能只需要此处理程序。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文