Version

Move the Bar Marker Automatically

This topic explains how you can configure the bar marker on your Linear gauge to move automatically. For example, if you created a Linear gauge to represent a thermometer, you could configure the mercury level to rise and fall, simulating a real thermometer.

This topic assumes that you already created a Linear gauge. For information on how to create a gauge, see Getting Started with WinGauge.

To move the needle automatically on your gauge:

  1. From the Component tab of the toolbox, drag the Timer component to your form.

  2. In the Properties window, set the Enabled property to True.

  3. In the component tray, double click the Timer component.

  4. The following example code accesses the bar marker on your Linear gauge and increases the value by 5. Place the code in the timer1_Tick method:

In Visual Basic:

Dim myLinearGauge As LinearGauge = Me.ultraGauge1.Gauges(0)' Access Bar marker
Dim myMarker As LinearGaugeMarker = myLinearGauge.Scales(0).Markers(0)
Dim currentValue As Double = CInt(myMarker.Value)
' Increases needle by 5
myMarker.Value = currentValue + 5

In C#:

LinearGauge myLinearGauge = this.ultraGauge1.Gauges[0] as LinearGauge;
// Access Bar marker
LinearGaugeMarker myMarker = myLinearGauge.Scales[0].Markers[0];
int currentValue = (int)myMarker.Value;
// Increase needle by 5
myMarker.Value = currentValue + 5;
  1. In the Properties window, click the Gauges property. Then, click the ellipsis (…) button to open the Gauges collection editor.

  2. Locate the Scales property and click the ellipsis (…) button to open the Scales collection editor.

  3. Locate the Markers property and click the ellipsis (…) button to open the Markers collection editor.

  4. Expand the Response property.

  5. Set the Enabled property to True. The RefreshRate property is the amount of time between each update of the gauge. Set the RefreshRate property to 00:00:00.1000000. The ResponseRate property is the amount of time taken for the marker to traverse the entire scale of the gauge. Set the ResponseTime property to 00:00:01. Setting the Response property gives your bar a smoother appearance as it increases along the scale; your bar marker doesn’t appear as if it is jumping from value to value.

  6. Save and run the application.