So Simple...

J

joey.powell

Does anyone know how to make the Leave event work for a regular
textbox? I have tried several times already...the event handlers are
there...it just doesn't fire when you tab off of the textbox and onto
another control. What gives?
 
B

Barry Kelly

Does anyone know how to make the Leave event work for a regular
textbox? I have tried several times already...the event handlers are
there...it just doesn't fire when you tab off of the textbox and onto
another control. What gives?

The following code works for me when tabbing of the two TextBoxes:

---8<---
using System;
using System.Drawing;
using System.Windows.Forms;

class App
{
static void Main()
{
Form form = new Form();
TextBox a = new TextBox();
a.Parent = form;
a.Location = new Point(10, 10);

TextBox b = new TextBox();
b.Parent = form;
b.Location = new Point(10, 40);

a.Leave += delegate
{
form.Text = "Left A";
};

b.Leave += delegate
{
form.Text = "Left B";
};

Application.Run(form);
}
}
--->8---

Is there something unusual or special about the structure of your form?

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top