user818700
user818700

Reputation:

Fire event on textbox lose focus

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.

Thanks!

Upvotes: 10

Views: 28715

Answers (5)

Zuabros
Zuabros

Reputation: 270

This will work:

Go to the "properties" of your textbox. You will see a yellow lightning bolt in the first line tab. There you will find all possible events that can be triggered. Search for "Leave" entry, double-click it. There you can put whatever you want.

Upvotes: 0

user13843293
user13843293

Reputation:

In WPF Try this: TextBox.LostFocus

Upvotes: 0

christian luketa
christian luketa

Reputation: 11

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
}

Upvotes: 0

Milan Aggarwal
Milan Aggarwal

Reputation: 5104

Please explore the LostFocus event in a textbox. Hope it helps

Upvotes: 6

ygssoni
ygssoni

Reputation: 7349

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

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

The code generated will be like :

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

Upvotes: 13

Related Questions