views:

2174

answers:

2

I'm working on a winforms jukebox in C#. I'd like to have a vertical progressbar for the volume control. Does anyone know how to do that?

+4  A: 

I don't know that I'd use a progress bar to control the volume, but to display the volume level you could use a user drawn control or you could just resize a label with a background color (that last method is kind of kludgy though)

The progress bar isn't meant to take input, no matter what the orientation.

If you really would like to control the volume, consider using a vertical scroll bar, or a trackbar with a vertical orientation.

For what it's worth, there's a discussion on how to create a vertical progress bar on MSDN, where they suggest doing this:

using System; 
using System.Windows.Forms; 

public class VerticalProgressBar : ProgressBar { 
  protected override CreateParams CreateParams { 
    get { 
      CreateParams cp = base.CreateParams; 
      cp.Style |= 0x04; 
      return cp; 
    } 
  } 
}

which sets the PBS_VERTICAL flag in Style.

Daniel LeCheminant
+1: "Works on my machine"
Sung Meister
+1 Thanks, this works very well.
Krakerjak
+4  A: 

You have to use the ProgressBarRenderer for that. It's documented in MSDN

The documentation actually shows implementation of a vertical ProgressBar, so it should make it easy for you. :-)

Ken White
+1 This solution worked, but the one Daniel left looked better.
Krakerjak
No problem. I just told you what Microsoft said you should do; it's their framework, after all. it's your choice whether to do it or not. :-)
Ken White