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.
To move the needle automatically on your gauge:
-
From the Component tab of the toolbox, drag the Timer component to your form.
-
In the Properties window, set the Enabled property to True.
-
In the component tray, double click the Timer component.
-
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:
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
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;
-
In the Properties window, click the Gauges property. Then, click the ellipsis (…) button to open the Gauges collection editor.
-
Locate the Scales property and click the ellipsis (…) button to open the Scales collection editor.
-
Locate the Markers property and click the ellipsis (…) button to open the Markers collection editor.
-
Expand the Response property.
-
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.
-
Save and run the application.