title: Vb.net Set focus to nested control on another open form
body: <p>I have a form that I open from a menu item on my main form that has a datagridview that contains a control name. When I click on the control name I'd like it to set focus back to the main form and focus the control. I can get it to work if the control name is a control on the current tab, but if I try to focus to a control on another tab on my main form it does not focus. I don't get an error, it just doesn't focus. </p>
  
  <p>Any assistance you could give me to point me in the right direction would be most appreciated. Thanks</p>
  
  <p>My main form consists of nested controls: </p>
  
  <p>Tabcontrol
    Tabpage 
       Groupbox 
          Control (such as textbox, etc) </p>
  
  <p>Here is my code from the 2nd form: </p>
  
  <pre><code>Public Property f1 As MainForm
  
     Private Sub DataGridView1_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
  
  
          For Each cont As Control In f1.Controls
  
              For Each Tp As TabPage In cont.Controls
  
                  For Each gbx As GroupBox In Tp.Controls
  
                      For Each ctrl As Control In gbx.Controls
  
  
                          If ctrl.Name = DataGridView1.SelectedCells(1).Value Then
                              ctrl.Focus()
                              Exit For
                          End If
  
  
  
  
                      Next ctrl
  
                  Next gbx
  
              Next Tp
  
          Next cont
  
          Me.Close()
  
  end sub 
  </code></pre>