Search code examples
c#winformsprogress-bar

how to make a vertical progress bar


I'm trying to make a vertical progress bar and I understand that there isn't any easy way to do it.

I've seen this code floating around the forums:

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

My question is where do I put this code? Does it go in my program.cs file or the form that the progress bar is on?


Solution

  • It doesn't matter where you put the code, you only have to make sure you are creating a VerticalProgressBar in your Form.Designer.cs file.

    You have to change

    private System.Windows.Forms.ProgressBar progressBar1
    

    to

    private VerticalProgressBar progressBar1
    

    (or whatever it is called) and

    this.progressBar1 = new System.Windows.Forms.ProgressBar();
    

    to

    this.progressBar1 = new VerticalProgressBar();