title: Activate treeview again
body: <p>I have two forms. The main form contains a <code>treeview</code>. After I show the second form, the treeview loses focus. That's okay, but I want to activate the treeview when the second form closes.</p>
  
  <p>Form1.cs</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>namespace ex
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              using (Form2 form2 = new Form2(this))
              {
                  form2.StartPosition = FormStartPosition.CenterParent;
                  form2.ShowDialog();
              }
          }
  
          internal void example()
          {
              treeView1.SelectedNode = treeView1.Nodes[1];
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              TreeNode node = new TreeNode("aaaa");
              treeView1.Nodes.Add(node);
              node = new TreeNode("bbbb");
              treeView1.Nodes.Add(node);
              node = new TreeNode("cccc");
              treeView1.Nodes.Add(node);
  
          }
      }
  }
  </code></pre>
  
  <p>Form2.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace ex
  {
      public partial class Form2 : Form
      {
          Form1 form1;
  
          public Form2(Form1 form1)
          {
              InitializeComponent();
  
              this.form1 = form1;
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              this.Close();
              form1.example();
  
              //not working
              form1.treeView1.Focus();
              form1.treeView1.Select();
          }
      }
  }
  </code></pre>