Click here to Skip to main content
Click here to Skip to main content
Go to top

Status Label - Showing Progress

, 23 Sep 2006
Rate this:
Please Sign up or sign in to vote.
Show application progress via a status label.

Sample Image - ItemSelection.jpg

Designer Preview

Introduction

Browsing the Internet, I was unable to find what I needed, and so decided to give it a crack myself. It does exactly what I wanted it to be capable of doing. However, I am still new to this, as such please excuse stupid errors and please give me constructive critism about the code and idea. Thank you!

Progress Bar

The problem with the ProgressBar is that I only knew when certain events had been triggered. Thus, the progress would pause in a position for a while and then suddenly jump, not giving a true representation of what was going on. I considered placing a label on the form that would update with the latest information. The issue here being that the user would have no indication as to how many steps were involved. Finally, the problem with this was 'cleanly' creating the labels and associated text for each task. Suffice to say, I wasn't happy with these ideas.

Solution

I decided I needed a reason to learn about Design-Time controls. Herein, this control was born. I decided that I wanted a control that could display the various tasks that needed to be accomplished, and basically tick them off as each task was completed. I also wanted to be able to display an image that would also show progress. The control has a few features, such as system drawn image (customizable colouring) when no image is present. Design time features include being able to add/delete status items straight in the editor, no coding necessary. It does what it's supposed to do, and definitely suits my application. Hopefully, this is useful for someone else too.

Control Usage

To begin using this control, it's as easy as doing the following. I will explain at the end!

Imports StatusLabel
Imports StatusLabel.StatusLabel
Imports StatusLabel.StatusItem

Public Class frmMain
   Inherits System.Windows.Forms.Form
   
   Dim Status As New StatusLabel.StatusLabel

   Private Sub AddItem()
      Dim si as new StatusItem

      si.Name = "Item1"
      si.Text = "Connecting"
      si.Status = CurrentStatus.None

      Status.Items.Add(si)
   End Sub

   Private Sub RemoveItemByIndex(ByVal Index As Int16)
      Status.Items.RemoveAt(Index)
   End Sub

   Private Sub RemoveItemByItem(ByVal Item As StatusItem)
      Status.Items.Remove(Item)
   End Sub

End Sub

End Class

Explanation

The imports are mostly to make the code easier to input. A simple reference to the DLL would be sufficient.

I have ommitted the location, size, etc... code since this article is focused on the control itself and its usage.

You add an item much like any other collection (ComboBox, ListBox, etc...). Next, you assign the item some a name, text, and a status. The available modes are:

  • None - No icon is shown and the text is not indented
  • Pending - The pending icon is shown and the text is indented
  • Running - The pending icon is shown and the text is indented and bold
  • Complete - The complete icon is shown and the text is indented, not bold

Altering a property is simple, and can be done much like any other control. The same goes for removing. An example of changing the status:

Status.Items.Item(0).Status = CurrentStatus.Pending

An example of changing an icon (GIF, JPG, PNG, ICO are all supported):

Status.CompleteImage = Image.FromFile("Some_File.jpg")

Features

  • GDI image displayed when no image available
  • Ellipsis (...) displayed automatically when status item is in running state
  • Customisable colours for box and tick
  • Tick and box can be replaced with images
  • Design-time support

Known Issues

Transparent images are supported, however if they are icons with a transparent colour, this colour will be shown. I wasn't able to work out how to fix this, if you know, please contact me and let me know.

Planned Updates

  • Support for transparent images
  • Text/image alignment
  • Autosizing
  • Design-time moving (up/down)
  • Progress bar inclusion showing total progress

License

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

Share

About the Author

Shahpour
Software Developer uSoftware
Australia Australia
Shaps currently works as the Senior Networks Administrator for a small IT company in Australia. He is also involved in various software developments, for Windows, Windows Mobile, iPhone, Mac and occasionally the web. His central focus in this area, is User Interface design.
 
If he had spare time, he'd play some tunes, read a book or visit the gym. Until then, he writes small applications for the iPhone that help improve his productivity at work.

Comments and Discussions

 
Generalgood PinmemberFoamox24-Oct-08 18:45 
GeneralSetup at Runtime Pinmembersimohack4-Feb-07 21:02 
GeneralVisual Basic 2003 Version Pinmemberdbaratelli11-Jan-07 2:43 
GeneralRe: Visual Basic 2003 Version PinmemberShahpour26-Jan-07 18:34 
GeneralAdding status Failed PinmemberBrian G01283-Oct-06 5:09 
GeneralRe: Adding status Failed Pinmembershaps803-Oct-06 5:23 
AnswerRe: Adding status Failed PinmemberSgtNerd6-Sep-07 0:06 

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 | Mobile
Web03 | 2.8.140916.1 | Last Updated 24 Sep 2006
Article Copyright 2006 by Shahpour
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid