Hi,
I have multiple text boxes and buttons.
On print button I am saving form as .xps using Me.PrintForm1.Print and I need to unselected all text boxes before this
and then again select same text box after save. Please suggest how can i do this functionality.
I tried with this.Activecontrol but always getting clicked button(i.e. print button). how I'll get last active control or is there any alternative.
Thanks
How do I find Last active control
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Nov 25, 2012, 8:04 AM EST
private TextBox lastTB = null;
private void textBox_Leave(object sender, System.EventArgs e)
{
lastTB = (TextBox)sender;
}
// after saving form, restore focus to last TB which had input focus
if(lastTB != null) lastTB.Focus();