title: C# progress bar change color
body: <p>I am trying to change the color of my progress bar, I'm using it as a password strength validator. For example, if the desired password is weak, the progress bar will turn yellow, if medium, then green. Strong, orange. Very strong, red. It's just something like that. Here's my code for the password strength validator:</p>
  <pre><code>var PassChar = txtPass.Text;
  
  if (txtPass.Text.Length &lt; 4)
      pgbPass.ForeColor = Color.White;
  if (txtPass.Text.Length &gt;= 6)
      pgbPass.ForeColor = Color.Yellow;
  if (txtPass.Text.Length &gt;= 12)
      pgbPass.ForeColor = Color.YellowGreen;
  if (Regex.IsMatch(PassChar, @&quot;\d+&quot;))
      pgbPass.ForeColor = Color.Green;
  if (Regex.IsMatch(PassChar, @&quot;[a-z]&quot;) &amp;&amp; Regex.IsMatch(PassChar, @&quot;[A-Z]&quot;))
      pgbPass.ForeColor = Color.Orange;
  if (Regex.IsMatch(PassChar, @&quot;[!@#\$%\^&amp;\*\?_~\-\(\);\.\+:]+&quot;))
      pgbPass.ForeColor = Color.Red;
  </code></pre>
  <p>The <code>pgbPass.ForeColor = Color.ColorHere</code> doesn't seem to be working. Any help? Thanks.</p>