如何删除从的WinForms一个TextBox的焦​​点? [英] How to remove the focus from a TextBox in WinForms?

查看:192
本文介绍了如何删除从的WinForms一个TextBox的焦​​点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从多个文本框删除焦点。我尝试使用:

I need to remove the focus from several TextBoxes. I tried using:

textBox1.Focused = false;

及其只读属性值是

我又试图将焦点设置在窗体上,以便从所有的文本框将其删除,但是这也不能工作:

I then tried setting the focus on the form, so as to remove it from all the TextBoxes, but this also fails to work:

this.Focus();

和函数返回当选择一个文本框。

and the function returns false when a textbox is selected.

那么,如何从一个TextBox清除病灶?

So, how do I remove the focus from a TextBox?

推荐答案

您需要一些其他可获得焦点的控制将焦点移到。

You need some other focusable control to move the focus to.

请注意,您可以将焦点设置到一个标签。你可能要考虑你想要的[Tab]键把它接下来。

Note that you can set the Focus to a Label. You might want to consider where you want the [Tab] key to take it next.

另外请注意,你不能将其设置为表格。状和面板容器控件将通过专注于他们的第一个孩子的控制。这可能是你想让它远离文本框。

Also note that you cannot set it to the Form. Container controls like Form and Panel will pass the Focus on to their first child control. Which could be the TextBox you wanted it to move away from.

这篇关于如何删除从的WinForms一个TextBox的焦​​点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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