How to change the color of progressbar in C .NET 3.5?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In WinForms on .NET 3.5, the built in ProgressBar is a wrapper over a native Windows control, and theme rendering decides most visual details. That is why changing ForeColor often has no visible effect. If you need reliable custom color, the practical approach is to draw your own control and keep progress updates thread safe.
Why the Default WinForms ProgressBar Ignores Color
The default control delegates painting to the operating system theme engine. In many environments this means BackColor and ForeColor are ignored for the fill area. You can still set value and style, but not arbitrary branding colors.
For teams with strict UI requirements, owner drawing is usually the only predictable solution. It also gives control over border, gradients, text overlays, and animation without depending on OS theme quirks.
Build a Colored Owner Drawn Progress Control
Create a small custom control that paints background, fill, and border. This example runs on .NET 3.5 WinForms.
This gives full control over color while keeping behavior close to the standard progress bar.
Update Progress Safely from Background Work
Long operations should not block the UI thread. Use BackgroundWorker in .NET 3.5 and update the custom control in ProgressChanged.
This pattern avoids cross thread exceptions and keeps drawing smooth during frequent updates.
Consider a Native Message Shortcut and Its Limits
Some developers use SendMessage with progress state messages to switch between pre defined visual states. This can show alternative colors such as warning or error in some Windows versions. It is not fully customizable and depends on OS theme support, so it is not a substitute for owner drawing when branding is strict.
If your requirement is simply to show success versus warning, native state messages can be enough. If the requirement is exact brand palette control, use a custom control.
Common Pitfalls
- Expecting the standard WinForms
ProgressBarto obeyForeColoron all machines. - Updating UI controls directly from worker threads, which causes thread access exceptions.
- Skipping double buffering in custom drawing, which creates visible flicker.
- Forgetting bounds checks for min, max, and value, causing negative widths or incorrect fill ratios.
- Redrawing too often during very small progress increments without throttling.
Summary
- In .NET 3.5 WinForms, the default progress bar does not provide reliable arbitrary color control.
- A custom owner drawn control is the most predictable solution for branded colors.
- Use
BackgroundWorkerto keep the interface responsive while work is running. - Validate range logic and enable double buffering for smooth rendering.
- Use native message based color states only for limited scenarios, not full customization.

