Click here to Skip to main content
Licence 
First Posted 30 Sep 2004
Views 107,321
Downloads 2,134
Bookmarked 52 times

Vertical ProgressBar

By | 1 Nov 2007 | Article
A vertical progressbar inherited from UserControl.

Sample Image - verticalprogressbar.jpg

Introduction

This is a very simple progress bar inherited from System.Windows.Forms.UserControl. The System.Windows.Forms.ProgressBar is only horizontal. And I cannot find a vertical version of a progress bar. I implemented this vertical progress bar with the same behavior as the horizontal progress bar. For my personal purpose, I provided this vertical progress bar with some enhanced features. First, the bar color can be changed by Color property. Second, the bar can be set to solid by setting Style property to Styles.Solid. The last feature is that the vertical progress bar can be borderless by setting BorderStyle property to BorderStyles.None.

Code

The code is very simple. The Styles and BorderStyles enums are defined as:

public enum Styles
{
    Classic, // same as ProgressBar
    Solid
}
public enum BorderStyles
{
    Classic, // same as ProgressBar
    None
}

The VerticalProgressBar class is inherited from UserControl class. You can specify a particular image by using the ToolboxBitmapAttribute class. Here, I used the same image as the ProgressBar.

[Description("Vertical Progress Bar")]
[ToolboxBitmap(typeof(ProgressBar))]
public sealed class VerticalProgressBar : System.Windows.Forms.UserControl
{
    ...    ...
}

For convenience, all of the vertical progress bar properties are organized into VerticalProgressBar category on the property window of Visual Studio .NET, using Category attribute.

[Description( "VerticalProgressBar Maximum Value")]
[Category( "VerticalProgressBar" )]
[RefreshProperties(RefreshProperties.All)]
public int Maximum
{
    get
    {
    return m_Maximum;
    }
    set
    {
    m_Maximum = value;
    if(m_Maximum < m_Minimum)
            m_Minimum=m_Maximum;
        if(m_Maximum < m_Value)
                m_Value = m_Maximum;
        Invalidate();
    }
}

... ...

OnPaint function was overridden to draw bar and border if needed.

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
    Graphics dc = e.Graphics;
    
    //Draw Bar
    drawBar(dc);

    //Draw Border
    drawBorder(dc);

    base.OnPaint(e);
}

Using the Code

To use this vertical progress bar, copy the VerticalProgressBar.dll under your project directory. Then choose Add/Remove Items.. on the context menu of toolbox pane, and select this file to add this control to the toolbox. It will show the same icon as the ProgressBar. Then you can use it as same as ProgressBar. The default properties of this vertical progress bar are set to the same as the ProgressBar. You can change Color, Style, and BorderStyle properties as you need.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jiajun Lu

Web Developer

United States United States

Member

I started programming 10 years ago on a 80286 PC with dbase system. Now, I am a graduate student of Texas A&M University. I am working on the research on Collaborative Systems. My works are on both Windows and Linux platform in C/C++ programming languages. I am pretty interested in .NET frameworks and C#, and adapt some works on .NET frameworks.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionVerticalProgressBar does not appear in the toolbox Pinmemberpetrus bitbyter3:13 17 Apr '12  
GeneralMy vote of 5 PinmemberJohn Smith Becera22:48 18 Oct '10  
GeneralTop Down Progress [modified] PinmemberHamsterhead200117:14 23 Mar '08  
JokeRe: Top Down Progress PinmemberIngenious00123:39 17 Jun '08  
GeneralNice PinmemberPaul Conrad7:50 4 Nov '07  
GeneralVisualStyles PinmemberThe_Mega_ZZTer9:55 2 Nov '07  
GeneralUpdated PinmemberJiajun Lu3:06 2 Nov '07  
GeneralRe: Updated PinmemberMember 61050220:03 25 Jun '09  
GeneralDerive from Control, not UserControl PinmemberSAKryukov6:42 23 Oct '07  
GeneralRe: Derive from Control, not UserControl Pinmembernorm .net1:49 2 Nov '07  
GeneralRe: Derive from Control, not UserControl PinmemberThe_Mega_ZZTer9:48 2 Nov '07  
GeneralRe: Derive from Control, not UserControl Pinmembernorm .net20:36 4 Nov '07  
GeneralRe: Derive from Control, not UserControl PinmvpJohn Simmons / outlaw programmer2:57 25 Nov '07  
Questionhow we differentiate word dll version Pinmemberram on c#21:41 11 Jun '07  
QuestionMultiple Color PinmemberReza Shojaie2:34 14 May '07  
AnswerRe: Multiple Color PinmemberJiajun Lu3:09 2 Nov '07  
QuestionCan I use it on VB .net? PinmemberMember #382687917:06 13 Feb '07  
AnswerRe: Can I use it on VB .net? PinmemberPaul Conrad7:49 4 Nov '07  
GeneralWindows Vertical Progressbar Pinmemberreflex@codeproject13:49 24 Sep '06  
AnswerRe: Windows Vertical Progressbar PinmemberGLMnet9:31 2 Aug '07  
GeneralMin. > 0 Pinmemberkeith.h21:23 14 Sep '06  
GeneralInfinite Loop Pinmemberteeinep3:14 11 Jul '06  
Generalflickering Pinmembermoli5:11 13 Oct '04  
GeneralRe: flickering PinsussAnonymous6:04 13 Oct '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 1 Nov 2007
Article Copyright 2004 by Jiajun Lu
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid