4
I’d like to do two things on my progress bar.
- Change color from green to red.
- Remove the blocks and create a color.
I’m using Visual Studio Community 2019 on Windows 10.
4
I’d like to do two things on my progress bar.
I’m using Visual Studio Community 2019 on Windows 10.
6
First, include this if you don’t have:
using System.Runtime.InteropServices;
Second, you can create a new class or place your code in a static class
existing nongeneric:
public static class ModificarCorProgressBar
{
[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);
}
}
How an extension method was created SetState
we can call you directly this way:
progressBar1.SetState(2)
Remembering that the second parameter in SetState
:
1 = normal (green)
2 = error (red)
3 = warning (yellow)
Using Windows 8 or higher with this method below, you can get something like this:
Already in Windows Vista and Windows 7 the result will be a little different (honestly even better)
This is an adaptation of reply given by user1032613 in the OS .
Browser other questions tagged c# .net winforms progress-bar
You are not signed in. Login or sign up in order to post.