title: WinForms Setting A label Forecolour when the next TextBox Control is focused
body: <p>Ok,</p>
  
  <p>It is common practice to have a Label followed by a TextBox. Imagine we have three Labels and three TextBoxes like this.</p>
  
  <p>Label1.Text = "User Name" TextBox1.Name = "tbUserName"; <br />
  Label2.Text = "Users Sex" TextBox2.Name = "tbUserSex"; <br />
  Label3.Text = "User Age" TextBox3.Name = "tbUserAge"; <br /></p>
  
  <p>When TextBox1 is Focused I want Label1.Forecolor to be White, else IndianRed <br>
  When TextBox2 is focused I want Label2.Forecolor to be White, else IndianRed... etc <br></p>
  
  <p>I thought I could do it with the TagIndex - which are correctly set. I tried TextBox1.GetNextControl(TextBox1, false); but that didn't work. Here is the code I have at present which doesn't work.</p>
  
  <pre><code>private void SetLabelFocus()
      {
          SetAllLablesToDefault();
  
          foreach (Control ctrl in panel1.Controls)
          {
              if (ctrl is TextBox)
              {
                  TextBox tb = ctrl as TextBox;
                  if(tb.Focused)
                  {
                      foreach (Control ctr in panel1.Controls)
                      {
                          if (ctr is Label)
                          {
                              Label L = ctrl as Label;
                              if (label1.TabIndex == (tb.TabIndex-1))
                              {
                                  label1.ForeColor = Color.White;
                              }
  
                          }
                      }
                  }
  
              }
          }
      }
  
      private void SetAllLablesToDefault()
      {
          foreach (Control ctrl in panel1.Controls)
          {
              if (ctrl is Label)
              {
                  Label c = ctrl as Label;
                  c.ForeColor = defaultTextColour;
  
              }
          }
      }
  </code></pre>
  
  <p>What currently happens when the SetLabelFocus() is called in Label2.Enter() all Labels turn white ... Now one thing that May cause problems is the Labels Forecolors are Application Bound as is the TextBoxes BackColor.</p>
  
  <p>Anyway, How can I get the previous label to the focused TextBox to change its forecolor?</p>
  
  <p>Cheers.</p>