Click here to Skip to main content
13,557,390 members
Click here to Skip to main content
Add your own
alternative version


31 bookmarked
Posted 10 Mar 2007

A fast and performing gauge, now in a dll for vb users

, 10 Mar 2007
Rate this:
Please Sign up or sign in to vote.
A short procedure for adding a nice gauge to your VS toolbox


For those of us looking to use the great gauge class that A.J. Bauer wrote, in a project. After spending a few hours bopping around the internet in search of a decent looking yet free gauge control, I finally landed on the code project article "A fast and performing gauge", but to my horror it was written in C# (me = VB guy) and it did not use a DLL for the gauge class. Now, I am still fairly new to .net developement, but I was determined to use the gauge class in my VB.Net app, and I didnt want to recode it all in a VB class. So, this is what I did.

1. Opened a VS2005 project and chose Visual C#/windows/Class Library

2. Cut the contents of the original projects agauge.cs into my new class code, overwriting everything that was autogenerated.

3. In the solution explorer window, I added the references to System.Drawing and System.Windows.Forms

4. Debugging some broken definitions led me to copy the following lines from Agauge.Designer.cs...

private Sytem.ComponentModel.Icontainer components = null;


private void InitializeComponent()
            components = new System.ComponentModel.Container();

...into the new class.cs code, just before the public Agauge() constructor...

//KO-Added for Conversion to DLL
private System.ComponentModel.IContainer components = null;

//KO-Added for Conversion to DLL
private void InitializeComponent()
    components = new System.ComponentModel.Container();

public AGauge()

    SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

5. A final edit to make the namespace match my project namespace AGauge, and I was ready to build the DLL.

6. From my original VB project, I opened the toolbox, right-clicked on it, selected "Chose Items..." and then browsed to my newly created DLL, click open, and voila! A new toolbox control appeared allowing me to drag the gauge onto my VB form.

7. I spent the next few hours gleefully tweaking the myriad properties to make a couple of custom gauges that I needed for my project.

I do not presume to think that this is best or only way to accomplish what I was trying to do, but it did work, and I think that is something worth sharing...

P.S. After using the control for awhile, it became painfully evident that there was a problem with the ScaleLinesMajorStepValue property, so I re-opened the DLL project and searched for the symbol. I am not sure why but the original code was restricting the value to a number between the current MinValue and MaxValue properties. On the surface, this may seem to make sense, but in practice, it was giving me a pain in the neck while trying to tweak the properties. In the modified code above, I simply changed it to be whatever value is entered into the property window. The original line of code accompanies my comment above the edit.

Lastly, I would like to thank A.J. Bauer for sharing his awesome gauge class.


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


About the Author

Web Developer
United States United States
Computer nerd since way before it was popular...
Test Engineer for an Embedded Computer Mfg'r

You may also be interested in...


Comments and Discussions

General? [modified] Pin
po_dunk3-Feb-09 1:51
memberpo_dunk3-Feb-09 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03-2016 | 2.8.180515.1 | Last Updated 11 Mar 2007
Article Copyright 2007 by keno2oo1
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid