Hook up the
LostFocus
event to each
TextBox
, all pointing to the same event handler. Then a Form level field to track a
TextBox
. Something like:
public Form1()
{
InitializeComponent();
textBox1.LostFocus += OnTextBox_LostFocus;
textBox2.LostFocus += OnTextBox_LostFocus;
textBox3.LostFocus += OnTextBox_LostFocus;
}
private TextBox LastAccessed = null;
private void OnTextBox_LostFocus(object sender, EventArgs e)
{
LastAccessed = sender as TextBox;
}
Now you know who, you can do what you want.