control LastControl = null; private void ActivateHandler(object sender, EventArgs e) { if (this.LastControl != null) this.LastControl.Focus(); } private void DeactivateHandler(object sender, EventArgs e) { this.LastControl = this.ActiveControl; }This is off the top of my head, but it should give you some ideas.
using System.Windows.Forms; >public class Test >{ > static void Main() > { > Application.Run(new MainForm()); > } >} > >class MainForm : Form >{ > public MainForm() > { > WindowState = FormWindowState.Maximized; > IsMdiContainer = true; > Form frm = new Childform(); > frm.MdiParent = this; > frm.Show(); > Form frm2 = new Childform(); > frm2.MdiParent = this; > frm2.Show(); > frm2.Left = 2000; > } >} > >class Childform : Form >{ > public Childform() > { > Controls.Add(new Mycontrols()); > } >} > >class Mycontrols : UserControl >{ > public Mycontrols() > { > TextBox tb1 = new TextBox(); > tb1.Text = "TextBox1"; > TextBox tb2 = new TextBox(); > Controls.Add(tb1); > tb2.Top = 100; > tb2.Text = "TextBox2"; > tb2.Select(); > Controls.Add(tb2); > } >}