Click here to Skip to main content
14,766,145 members
Articles » General Reading » Uncategorised Technical Blogs » General
Technical Blog
Posted 29 Aug 2012

Tagged as



33 bookmarked

(AGauge) WinForms Gauge Control

Rate me:
Please Sign up or sign in to vote.
4.96/5 (25 votes)
29 Aug 2012Zlib
(AGauge) WinForms Gauge control


Image 1

Original AGauge control

AGauge is a gauge control for WinForms create by A.J.Bauer using GDI+. The original code was published in "Code Project - A fast and performing gauge" The version that I published here is an improved version of AGauge which contains the following changes.


Dynamic Gauge Label and Gauge Range

Properties for gauge label (previously known as CapText) and range are grouped into GaugeRanges and GaugeLabels which allow us to create any number of range and label as we wish. Range and label can be edited either from code or using the collection editor from the properties window.

System.ComponentModel.Description("Gauge Ranges.")]
public AGaugeRangeCollection GaugeRanges { get { return _GaugeRanges; } }
private AGaugeRangeCollection _GaugeRanges;

System.ComponentModel.Description("Gauge Labels.")]
public AGaugeLabelCollection GaugeLabels { get { return _GaugeLabels; } }
private AGaugeLabelCollection _GaugeLabels;

Besides, each label can use different Font settings since label is an instance of AGaugeLabel.

Image 2

Added NeedleType Enumeration

AGauge control has 2 different types of needle design selectable from NeedleType property. Type of NeedleType property was changed from Int32 (0 or 1) to enumeration type (NeedleType.Advance or NeedleType.Simple) to avoid invalid entry from user.

Image 3


Update ValueInRangeChangedEvent

ValueInRangeChangedDelegate was changed to ValueInRangeChangedEvent to allow multiple subscriptions. The event is changed to trigger only if value is entering or leaving a defined range. Besides, ValueInRangeChangedEventArgs was updated to hold current range and gauge value.

[Description("This event is raised if the value is entering or leaving
  defined range.")]
public event EventHandler<ValueInRangeChangedEventArgs> ValueInRangeChanged;
private void OnValueInRangeChanged(AGaugeRange range, Single value)
  EventHandler<ValueInRangeChangedEventArgs> e = ValueInRangeChanged;
  if (e != null) e(this, new ValueInRangeChangedEventArgs(range, value,

/// <summary>
/// Event argument for <see cref="ValueInRangeChanged"/> event.
/// </summary>
public class ValueInRangeChangedEventArgs : EventArgs
  /// <summary>
  /// Affected GaugeRange
  /// </summary>
  public AGaugeRange Range { get; private set; }
  /// <summary>
  /// Gauge Value
  /// </summary>
  public Single Value { get; private set; }
  /// <summary>
  /// True if value is within current range.
  /// </summary>
  public bool InRange { get; private set; }
  public ValueInRangeChangedEventArgs(AGaugeRange range, Single value,
                                          bool inRange)
    this.Range = range;
    this.Value = value;
    this.InRange = inRange;

Added ValueChangedEvent

ValueChanged event is added to notify user whenever gauge value is updated. Note that attempting to set gauge value out of defined gauge range will not trigger this event.

[Description("This event is raised when gauge value changed.")]
public event EventHandler ValueChanged;
private void OnValueChanged()
  EventHandler e = ValueChanged;
  if (e != null) e(this, null);


This article, along with any associated source code and files, is licensed under The zlib/libpng License


  • 28/08/2012: Initial release (Version 2.0.0)


This article, along with any associated source code and files, is licensed under The zlib/libpng License


About the Author

Code Artist
Technical Lead
Malaysia Malaysia
Official Page:

Comments and Discussions

QuestionNice control Pin
Cabiblanco7-Feb-21 3:27
MemberCabiblanco7-Feb-21 3:27 
QuestionThe DLL will not add to my Pin
YorkshireCap29-Oct-20 7:22
MemberYorkshireCap29-Oct-20 7:22 
I started a question thread in the general section (see before realising this section was here, directly related to the control.

Basically, I downloaded the dll and tried to add it as a tool to the toolbox in my vs2008 VB.Net (on Windows 7). It does not appear. I tired dragging the dll into the toolbox and tried the menu to add it. On advice from members of the forum, I tried adding a reference but that doesn't work either.
Then tried unblocking the file (yes,Windows had blocked it), but still will not add.
Does someone here know why it won't add and can you tell me how to overcome this hitch?

Thank you.

UPDATE: Henry Z. has now solved my issue. It seems this gauge control was made in framework 4.5 so is incompatible with VS2008. Other users please note.

modified 31-Oct-20 11:50am.

QuestionTrying to use your Agauge example as a wind direction dial but can't seem to get rid of the red arc. Also your links do not download. Pin
Member 136297721-Oct-19 3:50
MemberMember 136297721-Oct-19 3:50 
PraiseVery nice custom control Pin
mzbas26-Aug-19 10:31
Membermzbas26-Aug-19 10:31 
QuestionSource code not available Pin
dekortix9-Sep-18 0:13
Memberdekortix9-Sep-18 0:13 
QuestionDownload error Pin
Member 1184856213-Feb-18 10:05
MemberMember 1184856213-Feb-18 10:05 
Questiongauge doesnt display properly Pin
Member 130262962-Jan-18 19:02
MemberMember 130262962-Jan-18 19:02 
AnswerRe: gauge doesnt display properly Pin
Code Artist7-Jan-18 1:14
professionalCode Artist7-Jan-18 1:14 
GeneralRe: gauge doesnt display properly Pin
Member 130262968-Jan-18 17:32
MemberMember 130262968-Jan-18 17:32 
NewsLink available Pin
kfh3-Jun-17 13:01
Memberkfh3-Jun-17 13:01 
QuestionSource Link Pin
Mehmet Erol Çakır25-Apr-17 23:56
MemberMehmet Erol Çakır25-Apr-17 23:56 
BugSource link appears to be broken Pin
Leester3375-Apr-17 20:06
MemberLeester3375-Apr-17 20:06 
QuestionIf only... Pin
Member 130395905-Mar-17 9:38
MemberMember 130395905-Mar-17 9:38 
QuestionGaugeLabels - Example Pin
Member 1260459813-Oct-16 13:40
MemberMember 1260459813-Oct-16 13:40 
GeneralMy vote of 5 Pin
Member 1198694816-Jan-16 3:09
MemberMember 1198694816-Jan-16 3:09 
QuestionGaugeRanges Pin
mreza805-Oct-15 23:49
Membermreza805-Oct-15 23:49 
QuestionCreate Linear Gauges Pin
smsheethal26-Aug-15 3:49
professionalsmsheethal26-Aug-15 3:49 
AnswerRe: Create Linear Gauges Pin
Code Artist1-Sep-15 4:15
professionalCode Artist1-Sep-15 4:15 
QuestionUsing the Gauge Pin
Paul Hartland22-Mar-15 7:53
MemberPaul Hartland22-Mar-15 7:53 
Questionscale the gauge Pin
dxtr morgan27-Jan-15 8:45
Memberdxtr morgan27-Jan-15 8:45 
AnswerRe: scale the gauge Pin
Code Artist28-Jan-15 3:25
professionalCode Artist28-Jan-15 3:25 
Questionm_maxValue Pin
jhnlk20-Mar-14 5:12
Memberjhnlk20-Mar-14 5:12 
QuestionaGauge Closed Pin
Member 992210316-Oct-13 13:10
MemberMember 992210316-Oct-13 13:10 
AnswerRe: aGauge Closed Pin
Code Artist22-Oct-13 4:46
professionalCode Artist22-Oct-13 4:46 
GeneralRe: aGauge Closed Pin
Member 992210323-Oct-13 1:21
MemberMember 992210323-Oct-13 1:21 

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.