Back to Devexpress

LinearScale.Ranges Property

corelibraries-devexpress-dot-xtragauges-dot-core-dot-model-dot-linearscale-12e0052e.md

latest3.6 KB
Original Source

LinearScale.Ranges Property

Provides access to the collection of custom ranges with which you can mark specific value ranges along the scale.

Namespace : DevExpress.XtraGauges.Core.Model

Assembly : DevExpress.XtraGauges.v25.2.Core.dll

NuGet Package : DevExpress.Gauges.Core

Declaration

csharp
public virtual RangeCollection Ranges { get; }
vb
Public Overridable ReadOnly Property Ranges As RangeCollection

Property Value

TypeDescription
RangeCollection

A RangeCollection object that represents a collection of ranges.

|

Remarks

Custom ranges are fixed bars that are used to mark specific value ranges along scales. To create a custom range, add a DevExpress.XtraGauges.Core.Model.LinearScaleRange object to the Ranges collection. A LinearScaleRange object specifies the start and end value for the range, the color, the start and end thickness of the range and other options.

When a scale’s value falls into a specific range, the range’s Enter event raises. When the value leaves the range, the Leave event raises.

Example

The following code shows how to add custom ranges to a linear gauge.

Two ranges are added to the LinearScale.Ranges collection. These are used to mark values from 0 to 300 in green, and values between 300 and 500 in red. The result is displayed below:

csharp
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraGauges.Core.Drawing;

linearScaleComponent1.BeginUpdate();
// Range 1.
LinearScaleRange range1 = new LinearScaleRange();            
range1.AppearanceRange.ContentBrush = new SolidBrushObject(Color.Red);
range1.StartValue = 300F;
range1.EndValue = 510F;
range1.ShapeOffset = -5F;
// Range 2.
LinearScaleRange range2 = new LinearScaleRange();
range2.AppearanceRange.ContentBrush = new SolidBrushObject(Color.Lime);
range2.StartValue = 0F;
range2.EndValue = 300F;            
range2.ShapeOffset = -5F;
// Add the ranges to the scale.
linearScaleComponent1.Ranges.AddRange(new IRange[] {range1, range2 } );
linearScaleComponent1.EndUpdate();
vb
Imports DevExpress.XtraGauges.Core.Model
Imports DevExpress.XtraGauges.Core.Drawing

linearScaleComponent1.BeginUpdate()
' Range 1.
Dim range1 As LinearScaleRange = New LinearScaleRange()
range1.AppearanceRange.ContentBrush = New SolidBrushObject(Color.Red)
range1.StartValue = 300F
range1.EndValue = 510F
range1.ShapeOffset = -5F
' Range 2.
Dim range2 As LinearScaleRange = New LinearScaleRange()
range2.AppearanceRange.ContentBrush = New SolidBrushObject(Color.Lime)
range2.StartValue = 0F
range2.EndValue = 300F
range2.ShapeOffset = -5F
' Add the ranges to the scale.
linearScaleComponent1.Ranges.AddRange(New IRange() {range1, range2 })
linearScaleComponent1.EndUpdate()

See Also

CreateRange()

LinearScale Class

LinearScale Members

DevExpress.XtraGauges.Core.Model Namespace