I'd like to do two things on my progress bar.
Any information about those two things I wonder how to accomplish will be greatfuly appreaciated!
Thanks.
OK, it took me a while to read all the answers and links. Here's what I got out of them:
Sample Results
The accepted answer disables visual styles, it does allow you to set the color to anything you want, but the result looks plain:
Using the following method, you can get something like this instead:
How To
First, include this if you haven't: using System.Runtime.InteropServices;
Second, you can either create this new class, or put its code into an existing static
non-generic class:
public static class ModifyProgressBarColor
{
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr w, IntPtr l);
public static void SetState(this ProgressBar pBar, int state)
{
SendMessage(pBar.Handle, 1040, (IntPtr)state, IntPtr.Zero);
}
}
Now, to use it, simply call:
progressBar1.SetState(2);
Note the second parameter in SetState, 1 = normal (green); 2 = error (red); 3 = warning (yellow).
Hope it helps!