C# 文本框上的火灾事件失去焦点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12726765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:13:56  来源:igfitidea点击:

Fire event on textbox lose focus

c#windows-phone-7eventstextbox

提问by

I'm trying to call a method as soon as a TextBox on my screen gets 'un-focused' if that makes any sense? The user types in a username and as soon as that textbox loses focus I want to fire an event that checks if that username is indeed available.

我正在尝试在屏幕上的 TextBox 变得“未聚焦”时立即调用一个方法,如果这有意义的话?用户输入用户名,一旦该文本框失去焦点,我想触发一个事件,检查该用户名是否确实可用。

Thanks!

谢谢!

采纳答案by ygssoni

There is a Control.Leavein C#, which I think is perfect for your purpose.

Control.Leave在 C# 中有一个,我认为它非常适合您的目的。

you can go to events of the textbox in visual studio, and find the Leaveevent.

你可以去visual studio中文本框的Leave事件,并找到该事件。

The code generated will be like :

生成的代码将类似于:

private void txtbox_Leave(object sender, EventArgs e)
{
            //Check for available operation Code
} 

回答by Milan Aggarwal

Please explore the LostFocusevent in a textbox. Hope it helps

LostFocustextbox. 希望能帮助到你

回答by christian luketa

select your object and to choose the panel of the properties and click on event.To unroll until LEAVE and double-click above.that will give you:

选择您的对象并选择属性面板并单击事件。展开直到离开并在上面双击。这将为您提供:

private void  object_Leave( object  sender,  EventArgs  e)
{
  ////put your code here
}