Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VB

Tracker - A Windows Form

1.14/5 (5 votes)
19 Apr 2008CPOL2 min read 1   257  
updated with a gribanchor feature, a bugfix and translated to c++/cli

Introduction

In 2002 Andelko Pavelic created a nice and simple example of a custom windows forms control for .net 1.0, it can be found at http://www.codeproject.com/KB/vb/tracker.aspx

I have updated the project to VS2005 and translated it to c++/cli. The result is a control for .net 2.0 that does almost exactly what the original did.

Background

For one of my projects I needed a custom control much like tracker, but it lacked a very small (but essential) feature, namely the ability to control the grid alignment. The grid "starts" at the top of the control and draws a horizontal like every x pixels. I needed it to "start" at the bottom, so when a control is resized, the grids stays anchored to the bottom of the control.

Because I use c++ and I dislike switching from one visual studio version to another, I have also converted it to c++/cli. To not disappoint the VB users, if have merged the additions back into the VB version. See below for both downloads.

Using the code

Using the control is no different than using the original. (or any other custom control) . Just add the tracker.dll to your control toolbox by right-clicking it in the custom section,
"choose items"->browse and select tracker.dll.

Points of Interest

The initial value of the graph was set to 50 in v1.0, in the VB version it is now set to 0, but in the c++ version you can change it by setting the static initialValue variable before creating the control. This is useful because the internal thread starting immediately after creating the control.

History

2002/?/? v1.0

The original by Andelko Pavelic

2008/04/19 v1.1

- fixed a bug in the grid display causing it to not always draw all vertical grid lines depending on the width/grid ratio

- added a property to specify the grid archor

- changed the update RefreshingTime property from four fixed values to an integer value in ms.


License

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