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!
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.
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.
To begin using this control, it's as easy as doing the following. I will explain at the end!
Public Class frmMain
Dim Status As New StatusLabel.StatusLabel
Private Sub AddItem()
Dim si as new StatusItem
si.Name = "Item1"
si.Text = "Connecting"
si.Status = CurrentStatus.None
Private Sub RemoveItemByIndex(ByVal Index As Int16)
Private Sub RemoveItemByItem(ByVal Item As StatusItem)
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 (
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")
- 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
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.
- Support for transparent images
- Text/image alignment
- Design-time moving (up/down)
- Progress bar inclusion showing total progress