title: FlowLayoutPanel not recognising it's controls
body: <p>I've been attempting to create a dynamic search function that utilises multiple User Controls (strips) to build the search conditions. The strings are being built properly, so no problem there. However when the search() function is called in the Module, the flowLayoutPanel no longer recognises that there are strips inside it (I've put message boxes in to track where they are lost).
  Any suggestions would be appreciated.</p>
  
  <p>**************frmAttributesSearch Class************************************************</p>
  
  <pre><code>Public Class frmAttributesSearch
  
      Private Sub btnAddCondition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNewCondition.Click
          FlowLayoutPanel1.Controls.Add(New UCAddAttribute)
          MsgBox("Controls are here when added: " &amp; FlowLayoutPanel1.Controls.Count)
      End Sub
  
      Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
          MsgBox("Still here on search click: " &amp; FlowLayoutPanel1.Controls.Count)
          dgPlayers.DataSource = search()
      End Sub
  
      Public Function buildFilterString()
          MsgBox("Still lost on buildFilterString: " &amp; FlowLayoutPanel1.Controls.Count)
          Dim myString As String = ""
  
          For Each strip As UCAddAttribute In FlowLayoutPanel1.Controls
              myString = myString + strip.cmbAttribute.SelectedItem &amp; " " &amp; strip.cmbEqualityFactor.SelectedItem &amp; " " &amp; Integer.Parse(strip.txtNumber.Text) &amp; " AND "
          Next
  
          myString = myString + "1 = 1"
  
          Return myString
  
      End Function
  
  End Class
  </code></pre>
  
  <p>**************Module*****************************************************************</p>
  
  <pre><code>Public Function search() As DataTable
  
          MsgBox("Lost here on search: " &amp; frmAttributesSearch.FlowLayoutPanel1.Controls.Count)
  
  Dim dt As New DataTable
          Dim Str As String = _
         &lt;String&gt; SELECT 
                      *
                  FROM 
                      Player
                  INNER JOIN Report ON Report.PlayerID = Player.PlayerID
                  WHERE                 
                  &lt;%= frmAttributesSearch.buildFilterString() %&gt;                    
                  ORDER BY 
                      ReportDate
         &lt;/String&gt;
          Try '@txtNumber&gt;&gt;&gt; was at the end of buildFilterString
              Using conn As New SqlClient.SqlConnection(DBConnection)
                  conn.Open()
                  Using cmdQuery As New SqlClient.SqlCommand(Str, conn)
                      Using daResults As New SqlClient.SqlDataAdapter(cmdQuery)
                          daResults.Fill(dt)
                      End Using
                  End Using
              End Using
  
          Catch ex As Exception
              MsgBox("Filter Search Exception: " &amp; ex.Message &amp; vbNewLine &amp; Str)
          End Try
  
          Return dt
  
      End Function
  </code></pre>