Click here to Skip to main content
13,405,744 members (51,893 online)
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

Generalcan't set value of gauge Pin
Member 765657716-May-11 13:50
memberMember 765657716-May-11 13:50 
GeneralTransparent background and dual scales Pin
George papas13-Jun-10 23:54
memberGeorge papas13-Jun-10 23:54 
SuggestionRe: Transparent background and dual scales Pin
pal800019-Jan-12 15:15
memberpal800019-Jan-12 15:15 
GeneralRe: Transparent background and dual scales Pin
George papas19-Jan-12 15:28
memberGeorge papas19-Jan-12 15:28 
GeneralRe: Transparent background and dual scales Pin
pal800019-Jan-12 17:30
memberpal800019-Jan-12 17:30 
GeneralStunning Code - well done Pin
Member 41331192-Apr-10 0:54
memberMember 41331192-Apr-10 0:54 
GeneralThank you. Pin
ntrp.ivan25-Mar-10 0:21
memberntrp.ivan25-Mar-10 0:21 
QuestionAssistance? Pin
JaredShaw13-Jan-10 12:24
memberJaredShaw13-Jan-10 12:24 
QuestionHow do you make the thing smaller. Pin
Idkfawin3210-Mar-09 16:58
memberIdkfawin3210-Mar-09 16:58 
General? [modified] Pin
po_dunk3-Feb-09 2:51
memberpo_dunk3-Feb-09 2:51 
QuestionHow do you get rid of the red? [modified] Pin
ErnestMoore7-May-08 5:33
memberErnestMoore7-May-08 5:33 
AnswerRe: How do you get rid of the red? Pin
sniiki8-Mar-09 1:28
membersniiki8-Mar-09 1:28 
GeneralRe: How do you get rid of the red? Pin
djsullivemerson30-Apr-09 10:58
memberdjsullivemerson30-Apr-09 10:58 
GeneralVS 2008 Pin
Raven00724-Apr-08 10:05
memberRaven00724-Apr-08 10:05 
Generaltransparent background Pin
spoogie9-Sep-07 21:35
memberspoogie9-Sep-07 21:35 
GeneralTHIS ISN'T VB.NET!! Pin
klaus@gubbernet.com20-Aug-07 9:31
memberklaus@gubbernet.com20-Aug-07 9:31 
GeneralRe: THIS ISN'T VB.NET!! Pin
Brian Batteiger17-Oct-07 9:31
memberBrian Batteiger17-Oct-07 9:31 
GeneralRe: THIS ISN'T VB.NET!! Pin
klaus@gubbernet.com11-May-08 6:37
memberklaus@gubbernet.com11-May-08 6:37 
GeneralRe: THIS ISN'T VB.NET!! Pin
-tusk-9-May-08 10:54
member-tusk-9-May-08 10:54 
GeneralRe: THIS ISN'T VB.NET!! Pin
klaus@gubbernet.com11-May-08 6:32
memberklaus@gubbernet.com11-May-08 6:32 
GeneralCool! Pin
KentuckyEnglishman13-Mar-07 7:00
memberKentuckyEnglishman13-Mar-07 7:00 
GeneralRe: Cool! Pin
keno2oo113-Mar-07 16:12
memberkeno2oo113-Mar-07 16:12 
GeneralRe: Cool! Pin
-tusk-9-May-08 10:54
member-tusk-9-May-08 10:54 

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 | 2.8.180221.1 | Last Updated 11 Mar 2007
Article Copyright 2007 by keno2oo1
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid