I need to make a Progress Bar on a StatusBarPanel Object to change it from any form on my project. Any Help?
Printable View
I need to make a Progress Bar on a StatusBarPanel Object to change it from any form on my project. Any Help?
I did it calling the DrawItem event of the StatusBar after setting the style of the StatusBarPanel to owner-draw. On the event I create a rectangle object to draw the progressbar. To set the width of the progress bar and refresh the StatusBarPanel I load the text property of the StatusBarPanel with the new width and take it from there to asign it to the rectangle.
I dont think this is the best way to do it and I have spend so many time on doing this. Please I need some help here...
I did a search on the forum and found your post as this is exactly what I am trying to do.
Balena's MS book says "Panels can have an owner-draw style, so you can define their appearance in the DrawItem event. For example, you might use this feature to display an animated icon or a progress Bar inside the Sataus Bar Control" - but dosn't tell us how to do it.
Have you progressed further with your code ( I know its an old post) or does any body know how to do this.
Can you show how you have achieved this so far - I don't care if you feel its messy - I'd just like make it work
Thanks Brian
I took different version I found on the web and adding my own thing to them and here is what I got. If I kept original code from another source then I kept a link to it in the code comments so you can see the source. This seems to be exactly what that event was meant for.
Hi Edneeis
thanks for the reply. However I am still a little lost as to how to use it - do you have some sample code of how to use this class to actually display a percentage type progress bar
regards
BH
That solution has an example of how to use it, sorry I didn't stick comments in that one.
Basically you can use it two ways you can either replace a normal panel in the statusbar with a progresspanel or just add a progresspanel directly to the status bar. The only different is what you pass into the contructor. Either pass a statusbarpanel object that you want to replace or a statusbar on which to add the new panel.
Here is some code to replace an existing panel:
VB Code:
Dim pnl As ProgressPanel Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'use the constructor below to replace an existing panel pnl = New ProgressPanel(StatusBarPanel1) 'set the autotext to show the percent of progress pnl.TextStyle = ProgressPanel.ProgressTextStyle.Percent pnl.TextAlignment = ContentAlignment.MiddleCenter 'set the max value pnl.Maximum = 10 pnl.Value = 5 'set the tooltip the same as the text pnl.ToolTipText = pnl.GetText(ProgressPanel.ProgressTextStyle.Percent) 'set the bar color, use the same color for a solid color otherwise it is gradient pnl.BarColor1 = Color.Red pnl.BarColor2 = Color.Green pnl.ForeColor = Color.White End Sub
thanks for your reply. The code was in your attachement after all and I can see how it works - it'sust what I need - thank you
regards
BH
This class is great!!! Thanks, Edneeis!!!
This class is great!!! Thanks, Edneeis!!!