title: How to use foreach for the textboxes in a panel
body: <p>I have 9 textboxes created in design time. By clicking a listbox (inglist created in design time) i select an item, IfThisExist(CmpStr) function verify if i've allready choosed this one. When I debug the value of CmpStr is passed to txt.Text but it's not displayed in on screen.</p>
  <pre><code>string CmpString;
  bool SelectedExist;
  CmpSt r = Convert.ToString(inglist.Items[inglist.SelectedIndex]);
  SelectedExist = IfThisExist(CmpStr);
  
  if (inglist.SelectedIndex &gt; -1 &amp;&amp; rows &gt; 0 &amp;&amp; SelectedExist == false)
  {
    foreach (Control txt in mypanel.Controls)
    {
      if (txt is TextBox &amp;&amp; txt.Text == &quot;&quot; )
      {
        txt.Text = CmpStr;
        break;
      }
      else if (txt is TextBox &amp;&amp; txt.Text == CmpStr)
          break;
    }
  </code></pre>
  <p>If I do same thing with the method below it works.</p>
  <pre><code>//for (int j = 0; j &lt; rows; ++j)
  //{
  //   switch (j + 1)
  //{
  //  case 1:
  //    if (textBox1.Text == &quot;&quot; &amp;&amp; textBox1.Text!= CmpStr) 
  //  {
  //    textBox1.Text = CmpStr;
  //  passed = true;
  //   }
  //  break;
  </code></pre>
  <p>.....</p>
  <p>What can be the reason ?</p>