C# progress bar change color

The Progress Bar Color cannot be changed in c# unless the the Visual Styles are Disabled.Although the IDE Offers to change the Color you will observe no color change as the progress bar will take up the visual style of the current operating system.You can opt to disable the visual style for your whole application.To do this go to the starting class of the program and remove this line from the code

 Application.EnableVisualStyles();

or use some custom progress bar control like this http://www.codeproject.com/KB/cpp/colorprogressbar.aspx


Find and remove Application.EnableVisualStyles(); from your aplication.

you can find many examples from here


Red tends to indicate errors or troubles -- please reconsider using red to indicate "strong password".

Also, because you're updating the color many many times based on potentially many matches, your colors won't be as consistent as you'd like.

Instead, give each of the conditions a score, and then choose your color based on the total score:

    int score = 0;

    if (txtPass.Text.Length < 4)
        score += 1;
    if (txtPass.Text.Length >= 6)
        score += 4;
    if (txtPass.Text.Length >= 12)
        score += 5;
    if (Regex.IsMatch(PassChar, @"[a-z]") && Regex.IsMatch(PassChar, @"[A-Z]"))
        score += 2;
    if (Regex.IsMatch(PassChar, @"[!@#\$%\^&\*\?_~\-\(\);\.\+:]+"))
        score += 3;

    if (score < 2) {
       color = Color.Red;
    } else if (score < 6) {
       color = Color.Yellow;
    } else if (score < 12) {
       color = Color.YellowGreen;
    } else {
       color = Color.Green;
    }

Note the use of an else-if construct that is sometimes easier than language-supplied switch or case statement. (The C/C++ one in particular is prone to buggy software.)