单击另一个表单时未触发Leave事件的表单上的文本框 [英] Textbox on a form not firing a Leave event when clicking on another form
问题描述
我有一个主窗体,它有一个菜单条,也有许多其他形式。
I have a main form that has a menu strip and that also is composed of many other forms.
我使用 提供设置弹出窗体(确切地说,DockContent或Dialog),可以通过主窗体上的菜单条打开。
I offer Settings using a pop-up form(to be exact, DockContent or Dialog) that can be opened via the menu strip on the main form.
设置窗体有一个文本框,其内容需要验证。
The Settings form has a Textbox whose content needs to be validated.
如果我点击弹出设置表单上的所有其他控件,该文本框上的离开事件将完全正常。
The leave event on that Textbox fires perfectly fine if I click on all other controls on the pop-up Settings form.
但它没有如果我在"设置"表单外单击,则会触发。
But it does not fire if I click on outside the Settings form.
有谁知道这是什么以及如何解决这个问题?
Does anyone know what this is about and how to go about resolving this?
问候,
推荐答案
尝试其他活动: LostFocus 。它可以添加到"设置"表单的
"加载"事件中。在C#中:
Try another event: LostFocus. It can be added inside the Load event of Settings form. In C#:
textBox1.LostFocus + = TextBox1_LostFocus;
。 。 。
private
void TextBox1_LostFocus(
object sender,EventArgs e)
{
...
. . .
}
这篇关于单击另一个表单时未触发Leave事件的表单上的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!