Change colors of ProgressBar control?

Z

Zytan

I am trying to change the colors of the ProgressBar control, using
ForeColor and BackColor, but this doesn't do anything. Does anyone
know why? I wonder if it has anything to do with Windows insistence
on drawing the ProgressBar with the block display, instead of one
smooth bar, even if you ask it to do otherwise?

Zytan
 
Z

Zytan

How are you telling it to show one smooth bar?

I have no idea. I guess I never tried doing it in C#, only in C++.
Is it possible to ask for this in C#? I can't find it anything under
appearance options.

Zytan
 
Z

Zytan

You can, like this:
progressBar1.Style = ProgressBarStyle.Continuous;
But, it doesn't work. I remember trying this before.

The docs say: "The Continuous style is valid only when visual styles
are not enabled."

Zytan
 
N

Nicholas Paldino [.NET/C# MVP]

Zytan,

The templates for a Windows Forms app for VS.NET 2005 puts the following
line into your code by default:

Application.EnableVisualStyles();

This says that you want to use visual styles in your application,
meaning that the .NET wrappers for common controls will use version 6, which
supports styling of the controls depending on theme and whatnot.

If you take this line out, you can set the value for the Style property
and get the smooth progress bar. However, the rest of the app will not have
visual styles set, which will look pretty out of place on Windows XP or
above.
 
Z

Zytan

The templates for a Windows Forms app for VS.NET 2005 puts the following
line into your code by default:

Application.EnableVisualStyles();

Oh, I didn't realize I had control over that, I thought it was a
global setting in WinXP.
This says that you want to use visual styles in your application,
meaning that the .NET wrappers for common controls will use version 6, which
supports styling of the controls depending on theme and whatnot.
Yes.

If you take this line out, you can set the value for the Style property
and get the smooth progress bar. However, the rest of the app will not have
visual styles set, which will look pretty out of place on Windows XP or
above.

Right, and that's no good. Thanks, Nicholas. I guess ProgressBars
are one thing Microsoft doesn't want us to mess with.

Zytan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top