如何模仿JavaScript的onBlur事件在Windows窗体?窗体、事件、JavaScript、onBlur

2023-09-04 12:27:53 作者:亡城以北゛

我有一个Windows窗体上的电话和电子邮件,文本框,我想在用户离开字段时验证。

I have phone and email textboxes on a Windows Form that I want to validate when the user leaves the fields.

当我双击在Visual Studio窗体设计器的文本框,它创建一个框TextChanged 事件。如想调用validate方法只有当用户完成输入完整的项目,不是每个按键后,这是不太合适的。

When I double click the textbox in Visual Studio form designer, it creates a textchanged event. This isn't quite suitable as want to call the validate method only when the user is done entering the full entry, not after every keystroke.

有没有办法在JavaScript中做到这一点类似于的onblur 事件?

Is there a way to do this similar to onBlur event in JavaScript?

我已经试过鼠标离开关闭聚焦,他们喜欢框TextChanged 。

I have tried MouseLeave, Off Focus, and they all act like TextChanged.

如何才能做到这一点?

推荐答案

尝试离开事件。导航到属性页的控件。

Try the Leave event. Navigate to the Property page for your control.

您可以简单地输入您将创建方法的名称。 preSS 输入和Visual Studio将创建适合你的方法。

You can simply type the name of the method you'll be creating. Press Enter and Visual Studio will create the method for you.