Click here to Skip to main content
Click here to Skip to main content

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

Introduction

For those of us looking to use the great gauge class that A.J. Bauer wrote, in a VB.net 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;

and...

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()
        {
            InitializeComponent();

            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.

License

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

Share

About the Author

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

Comments and Discussions

 
Generalcan't set value of gauge PinmemberMember 765657716-May-11 12:50 
GeneralTransparent background and dual scales PinmemberGeorge papas13-Jun-10 22:54 
SuggestionRe: Transparent background and dual scales Pinmemberpal800019-Jan-12 14:15 
GeneralRe: Transparent background and dual scales PinmemberGeorge papas19-Jan-12 14:28 
GeneralRe: Transparent background and dual scales Pinmemberpal800019-Jan-12 16:30 
GeneralStunning Code - well done PinmemberMember 41331191-Apr-10 23:54 
GeneralThank you. Pinmemberntrp.ivan24-Mar-10 23:21 
QuestionAssistance? PinmemberJaredShaw13-Jan-10 11:24 
QuestionHow do you make the thing smaller. PinmemberIdkfawin3210-Mar-09 15:58 
General? [modified] Pinmemberpo_dunk3-Feb-09 1:51 
QuestionHow do you get rid of the red? [modified] PinmemberErnestMoore7-May-08 4:33 
AnswerRe: How do you get rid of the red? Pinmembersniiki8-Mar-09 0:28 
GeneralRe: How do you get rid of the red? Pinmemberdjsullivemerson30-Apr-09 9:58 
GeneralVS 2008 PinmemberRaven00724-Apr-08 9:05 
Generaltransparent background Pinmemberspoogie9-Sep-07 20:35 
GeneralTHIS ISN'T VB.NET!! Pinmemberklaus@gubbernet.com20-Aug-07 8:31 
GeneralRe: THIS ISN'T VB.NET!! PinmemberBrian Batteiger17-Oct-07 8:31 
I for one am glad it was posted here. I was looking for a gauge I could use in VB.net and this artical is a great solution showing how to use this gauge programed in a different language in your VB.Net code. So I think your comment was kind of rude.
GeneralRe: THIS ISN'T VB.NET!! Pinmemberklaus@gubbernet.com11-May-08 5:37 
GeneralRe: THIS ISN'T VB.NET!! Pinmember-tusk-9-May-08 9:54 
GeneralRe: THIS ISN'T VB.NET!! Pinmemberklaus@gubbernet.com11-May-08 5:32 
GeneralCool! PinmemberKentuckyEnglishman13-Mar-07 6:00 
GeneralRe: Cool! Pinmemberkeno2oo113-Mar-07 15:12 
GeneralRe: Cool! Pinmember-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 | Mobile
Web03 | 2.8.141015.1 | Last Updated 11 Mar 2007
Article Copyright 2007 by keno2oo1
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid