Click here to Skip to main content
15,905,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can i programmatically create a ProgressBar having multiple color as its bar style?
similar to These Progress Bar's

What I have tried:

Having no idea...
Please help!!
Thank you in advance...
Posted
Updated 23-Feb-21 2:46am
v3

If you have no idea, then the first thing to do is look at the classes that are available and see whether you can customize them: progressbar c# - Google Search[^]. You may even find a sample that someone else has already done.
 
Share this answer
 
OK - I'll give you some idea.

What is a progress bar, really? It's a rectangle who's size varies.

OK - define some rectangle you wish to represent your entire piece of work.
Draw that rectangle (filled or outlines or even invisible).
Now determine how you will report the progress of your job, whatever it is, on some periodic basis, to the application.
Use that value and some arithmetic to calculate what fraction of the work is done.
Use that value to calculate the size of a rectangle that is that fraction of your original rectangle.
Draw it so that it is visible.
When your job is complete the original rectangle will be filled.

Now, if you want to actually draw a rectangle with progress varying in color along the length of the rectangle then you need to do the slightly more complex idea of drawing the rectangle fill-progress as either (1) a gradient, or (2) a series of lines. Since you were a bit clueless at the basic level, I'd stick to the first example if I were you.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900