Click here to Skip to main content
11,709,220 members (57,145 online)
Click here to Skip to main content

Progress Task List Control

, 12 Sep 2005 57.2K 615 70
Rate this:
Please Sign up or sign in to vote.
A simple control to display a list of tasks, being ticked off as they are completed by the program.

Sample Image

Introduction

With some tasks, you just need a progress bar to tell the user how fast a task is going. You may have used a label or status bar with a progress bar, to tell the user what task is currently being performed. This control shows all the tasks that need to be performed, and ticks them off one by one as they are completed.

Using the code

It's very easy to use this control. Just add a reference in your Windows Forms project to ProgressTaskList.dll (contained in the source and demo projects). If it doesn't appear in the VS toolbox, you can right-click and 'Add/Remove Items', browse to the DLL and click OK. Then simply drag it on to your form surface.

You can set the tasks through the Visual Studio designer. See the 'TaskItems' property, and click the (Collection) button to edit the items. Put one task on each line.

Alternatively, you can set the tasks programmatically:

// To add items programatically, use the following syntax:
this.progressTaskList1.TaskItems.AddRange(new string[]{"Loading", 
       "Initialising", "Whatever", "Saving"});

// or you can just use the normal Add() method
this.progressTaskList1.TaskItems.Add("Loading");
this.progressTaskList1.TaskItems.Add("Initialising");
...

You need to call Start() to draw the tasks in the control, and after that call NextTask() whenever a task is completed, to advance to the next task.

Points of Interest

I was amazed to find that the Panel control has a built-in function called ScrollControlIntoView which ensures that the specified control is visible. I was about to go and write my own one, but lo and behold it was there. I used this method to ensure that the current task is always visible. As can be seen in the screenshot to the right, if there are too many tasks to fit in the panel surface, the control handles scrolling gracefully, thanks to the AutoScroll property of the Panel.

How it works

The control has a property called TaskItems which is a string[], corresponding to the tasks needing to be performed. I should point out that there is no link between the control and the thread running the task. So in order to update the control to the next task, the program must call NextTask() on the control after each task is complete.

When the Start() method is invoked on the control, the labels are created dynamically and added to the panel. Each label has an image on its left hand side, which changes from an arrow to a tick when the task is finished.

It's quite simple really. The hardest part (by far) was getting the TaskItems collection property to work through the VS designer. It was a useful exercise in control design.

Conclusions

Feel free to use this control and modify it as you please. If you have the time, post any improvements you make to the control here (as a comment), and I'll update the article.

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

Share

About the Author

Tim_Mackey
Web Developer
Ireland Ireland
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionSource Code VB Pin
rgaspar3-Apr-09 3:54
memberrgaspar3-Apr-09 3:54 
AnswerRe: Source Code VB Pin
Tim_Mackey3-Apr-09 6:17
memberTim_Mackey3-Apr-09 6:17 
GeneralRe: Source Code VB Pin
rgaspar3-Apr-09 10:33
memberrgaspar3-Apr-09 10:33 
GeneralCommercial Usage Pin
Eric SE26-Jul-07 16:11
memberEric SE26-Jul-07 16:11 
GeneralRe: Commercial Usage Pin
Tim_Mackey26-Jul-07 21:50
memberTim_Mackey26-Jul-07 21:50 
GeneralMessage Automatically Removed Pin
27-Dec-10 8:43
memberoutpan27-Dec-10 8:43 
QuestionImages Pin
salsafyren228-Mar-06 0:19
membersalsafyren228-Mar-06 0:19 
AnswerRe: Images Pin
Tim_Mackey28-Mar-06 0:23
memberTim_Mackey28-Mar-06 0:23 
QuestionAbout BeginInvoke()? Pin
firerainbow7-Oct-05 3:56
memberfirerainbow7-Oct-05 3:56 
AnswerRe: About BeginInvoke()? Pin
Tim_Mackey7-Oct-05 5:40
memberTim_Mackey7-Oct-05 5:40 
GeneralRe: About BeginInvoke()? Pin
firerainbow8-Oct-05 5:06
memberfirerainbow8-Oct-05 5:06 
GeneralSource & Demo File Names Pin
fwsouthern15-Sep-05 18:00
memberfwsouthern15-Sep-05 18:00 
AnswerRe: Source & Demo File Names Pin
Tim_Mackey15-Sep-05 23:16
memberTim_Mackey15-Sep-05 23:16 
GeneralRe: Source & Demo File Names Pin
fwsouthern16-Sep-05 16:47
memberfwsouthern16-Sep-05 16:47 
GeneralVery cool Pin
Tomasz Bekasiewicz12-Sep-05 11:43
memberTomasz Bekasiewicz12-Sep-05 11:43 
AnswerRe: Very cool Pin
Tim_Mackey12-Sep-05 11:59
memberTim_Mackey12-Sep-05 11:59 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150819.1 | Last Updated 12 Sep 2005
Article Copyright 2005 by Tim_Mackey
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid