为什么更改TextBox.UseSystemPasswordChar属性会调用TextBox.Focus()方法? [英] Why is the changing of TextBox.UseSystemPasswordChar property invokes the TextBox.Focus() method?

查看:57
本文介绍了为什么更改TextBox.UseSystemPasswordChar属性会调用TextBox.Focus()方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在stackoverflow的此处发布问题标题为为什么我不能使用tab离开TextBox?.在我的代码中,我更改了 TextBox.Leave 事件中的 TextBox.UseSystemPasswordChar 属性的值,并防止该事件通过 TAB 键,只要在执行设置 TextBox.UseSystemPasswordChar 的行时调用 TextBox.Focus()方法即可.

I post a question here in stackoverflow entitled Why can't I leave a TextBox using tab?. In my code, I change the value of TextBox.UseSystemPasswordChar property in the TextBox.Leave event and it prevents it to focus to other control through TAB key by invoking the TextBox.Focus() method whenever the line of setting the TextBox.UseSystemPasswordChar is executed.

Thomas软件

在测试期间,我也尝试将其作为正常事件添加到 TextBox 上,并得到相同的结果.我确实注意到,在按下 TAB 时,它确实暂时失去了焦点,但是在设置 UseSystemPasswordChar 时,它立即重新调整了控件的焦点.

During my testing, I tried implmenting it as normal events on the TextBox as well, with the same result. I did notice that it does temporarily lose focus when the TAB was pressed, but it then immediately refocused the control when UseSystemPasswordChar was set.

我的问题是为什么更改TextBox.UseSystemPasswordChar属性会调用TextBox.Focus()方法,如何防止它调用?

推荐答案

我不知道发生这种情况的原因.一种解决方法是使用以下方法设置自定义密码char: TextBox.PasswordChar ='●'

I don't know the reason this happens. A workaround is to set a custom password char with: TextBox.PasswordChar = '●'

使用以下命令将其重置为普通文本:

Reset it to normal text with:

TextBox.PasswordChar ='\ 0'

这不会触发焦点更改IME.

This doesn't trigger focus change IME.

这篇关于为什么更改TextBox.UseSystemPasswordChar属性会调用TextBox.Focus()方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆