Click here to Skip to main content
11,796,774 members (71,501 online)
Click here to Skip to main content

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

, 10 Mar 2007 56.7K 2.2K 31
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 12:50
memberMember 765657716-May-11 12:50 
GeneralTransparent background and dual scales Pin
George papas13-Jun-10 22:54
memberGeorge papas13-Jun-10 22:54 
SuggestionRe: Transparent background and dual scales Pin
pal800019-Jan-12 14:15
memberpal800019-Jan-12 14:15 
GeneralRe: Transparent background and dual scales Pin
George papas19-Jan-12 14:28
memberGeorge papas19-Jan-12 14:28 
GeneralRe: Transparent background and dual scales Pin
pal800019-Jan-12 16:30
memberpal800019-Jan-12 16:30 
GeneralStunning Code - well done Pin
Member 41331191-Apr-10 23:54
memberMember 41331191-Apr-10 23:54 
GeneralThank you. Pin
ntrp.ivan24-Mar-10 23:21
memberntrp.ivan24-Mar-10 23:21 
QuestionAssistance? Pin
JaredShaw13-Jan-10 11:24
memberJaredShaw13-Jan-10 11:24 
I'm a newb & haven't been able to get this to work. I'm using VS 2008 Express.
I created a project without the edits noted in the article (they were throwing errors for me), outside of that, I followed all of the steps.
QuestionHow do you make the thing smaller. Pin
Idkfawin3210-Mar-09 15:58
memberIdkfawin3210-Mar-09 15:58 
General? [modified] Pin
po_dunk3-Feb-09 1:51
memberpo_dunk3-Feb-09 1:51 
QuestionHow do you get rid of the red? [modified] Pin
ErnestMoore7-May-08 4:33
memberErnestMoore7-May-08 4:33 
AnswerRe: How do you get rid of the red? Pin
sniiki8-Mar-09 0:28
membersniiki8-Mar-09 0:28 
GeneralRe: How do you get rid of the red? Pin
djsullivemerson30-Apr-09 9:58
memberdjsullivemerson30-Apr-09 9:58 
GeneralVS 2008 Pin
Raven00724-Apr-08 9:05
memberRaven00724-Apr-08 9:05 
Generaltransparent background Pin
spoogie9-Sep-07 20:35
memberspoogie9-Sep-07 20:35 
GeneralTHIS ISN'T VB.NET!! Pin
klaus@gubbernet.com20-Aug-07 8:31
memberklaus@gubbernet.com20-Aug-07 8:31 
GeneralRe: THIS ISN'T VB.NET!! Pin
Brian Batteiger17-Oct-07 8:31
memberBrian Batteiger17-Oct-07 8:31 
GeneralRe: THIS ISN'T VB.NET!! Pin
klaus@gubbernet.com11-May-08 5:37
memberklaus@gubbernet.com11-May-08 5:37 
GeneralRe: THIS ISN'T VB.NET!! Pin
-tusk-9-May-08 9:54
member-tusk-9-May-08 9:54 
GeneralRe: THIS ISN'T VB.NET!! Pin
klaus@gubbernet.com11-May-08 5:32
memberklaus@gubbernet.com11-May-08 5:32 
GeneralCool! Pin
KentuckyEnglishman13-Mar-07 6:00
memberKentuckyEnglishman13-Mar-07 6:00 
GeneralRe: Cool! Pin
keno2oo113-Mar-07 15:12
memberkeno2oo113-Mar-07 15:12 
GeneralRe: Cool! Pin
-tusk-9-May-08 9:54
member-tusk-9-May-08 9:54 

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 | Terms of Use | Mobile
Web04 | 2.8.151002.1 | Last Updated 11 Mar 2007
Article Copyright 2007 by keno2oo1
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid