1

Situation:

I'm working on a new application that starts on opening a timer, when the timer ticks a progressbar loads.

What I want to do:

The basic thing I want is just change the color of the green bar. For example to blue.

My Problem:

I tried to change the color, if I look in the Properties Window of my progressbar, I can change the BackColor and ForeColor. Exactly as I did.

Now, I'm sure I did change the color but the changes doesn't seem to affect the progressbar.

It does not seem to change at all.. It still stays grey and green.

Is it possible to change this?

Maybe I need some code(C# or .NET)? (no need to tell the exact code, some basic pricipe is good)

Thank You

DonDjango
  • 84
  • 1
  • 9
  • Solution: use WPF. the WPF progress bar allows to change the bar color and keeps the style defined by the Windows theme. – Federico Berasategui Jun 12 '13 at 17:15
  • @HighCore I'm sorry if I'm looking noob now.. But I'm not a professional programmer, what do mean by WPF Progressbar..? Do I have to import it? Or is I an item in the toolbox? – DonDjango Jun 12 '13 at 17:20
  • WPF is an alternative to Windows Forms. – It'sNotALie. Jun 12 '13 at 17:20
  • 1
    There is a *huge* difference between the two. Are you building a Windows Form ? Or a Windows presentation foundation (WPF) ? Is there some XAML in it ? ex : `` – phadaphunk Jun 12 '13 at 17:21
  • @newstackexchangeinstance WPF is the `replacement` of winforms. – Federico Berasategui Jun 12 '13 at 17:21
  • @HighCore I prefer the term : `successor` :) Nothing could replace WinForms in my heart.. – phadaphunk Jun 12 '13 at 17:22
  • Use WPF or if you really need to use Winforms read [this](http://stackoverflow.com/questions/778678/how-to-change-the-color-of-progressbar-in-c-sharp-net-3-5) – Peuczynski Jun 12 '13 at 17:23
  • @phadaphunk you can't be serious. It's the least customizable, scalable thing I've seen in my whole life. – Federico Berasategui Jun 12 '13 at 17:23
  • I'm using a simple windows form. With a progressbar from the toolbox. – DonDjango Jun 12 '13 at 17:23
  • 1
    This used to work 13 years ago, before XP came around. Back then, Windows didn't have Visual Styles yet. Nowadays the progress bar is rendered with the style that the user selected. Which includes the color, green on Vista and up for the default Windows theme. You can disable visual styles for your program, just change the call in your Main() method. It will however look like a program that was raised from the dead. Creating your own ProgressBar control is very simple, it is an easy control to implement. You can make it look any way you want. – Hans Passant Jun 12 '13 at 17:24
  • @DonDjango there's no "toolbox" in WPF. You create your UI by defining it in XAML, and then use `DataBinding` to make it work with your data and logic. – Federico Berasategui Jun 12 '13 at 17:24
  • possible duplicate of [How to drawn my own progressbar on winforms?](http://stackoverflow.com/questions/3824876/how-to-drawn-my-own-progressbar-on-winforms) – Hans Passant Jun 12 '13 at 17:25
  • So can anyone give me a simple, well explained answer? Because everyone is saying something and I'm not that professional.. I'm sorry.. But I still do not understand the WPF.. I'm using visual studio..? – DonDjango Jun 12 '13 at 17:28
  • @DonDjango see the comment and linked question from Hans. That should have what you need. – Jeffrey Blake Jun 12 '13 at 17:59

1 Answers1

1

Locate the following line of code within your solution (tipically in Program.cs):

Application.EnableVisualStyles();

Comment out this line. Now the color of the progress bar will change as expected, but the style of your controls will also change a little. I'm curremtly trying to find a better solution for this myself.

Vlad Tamas
  • 180
  • 4
  • 9