Back to Devexpress

XRGauge Class

xtrareports-devexpress-dot-xtrareports-dot-ui.md

latest5.7 KB
Original Source

XRGauge Class

A control that allows you to embed graphical gauges in a report.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public class XRGauge :
    XRControl
vb
Public Class XRGauge
    Inherits XRControl

The following members return XRGauge objects:

Remarks

To add a gauge to a report, drag the XRGauge item from the DX:25.2: Report Controls Toolbox tab and drop the item onto the report.

Warning

The XRGauge export is unavailable in applications that use the System.Drawing.Common package v7 and higher in non-Windows environments.

Cusomize Appearance

The following properties allow you to customize the gauge appearance:

|

A linear horizontal dark gauge

|

A circular half light gauge

| | --- | --- | |

|

|

Note

The above XRGauge properties allow you to make basic changes to gauge appearance. Advanced gauge customization is available in code only. Refer to the following repository for information on advanced gauge customization: Advanced Gauge Customization

Set Values and Limits

The Actual Value property allows you to specify the value a gauge displays. The Target Value property sets the position of the target value marker. The Maximum and Minimum properties specify the gauge’s maximum and minimum value.

The following example shows a circular gauge whose Actual Value , Target Value , Maximum , and Minimum properties are set to 3, 7, 0, and 10 respectively.

Bind to Data

You can click the control’s smart tag to bind the gauge’s Actual Value , Target Value , Maximum , and Minimum properties to data. In the invoked action list, expand the drop-down Expression list for one of the properties and specify the data field or expression to which the property should be bound.

Create a Gauge in Code

The following example demonstrates how to create the XRGauge control in code and bind it to data. In this example, the report is bound to the Northwind database and the Product table is specified as a data member.

csharp
using DevExpress.XtraGauges.Core.Customization;
using DevExpress.XtraReports.UI;
//...

// Create a gauge and customize its appearance.
var gauge = new XRGauge() {
    ViewType = DashboardGaugeType.Linear,
    ViewStyle = DashboardGaugeStyle.Horizontal,
    ViewTheme = DashboardGaugeTheme.FlatDark,
    Minimum = 0, Maximum = 50
};

// Specify an expression for the gauge's "ActualValue" property.
gauge.ExpressionBindings.Add(
    new ExpressionBinding("ActualValue", "[UnitPrice]")
);
vb
Imports DevExpress.XtraGauges.Core.Customization
Imports DevExpress.XtraReports.UI
'...

' Create a gauge and customize its appearance.
Private gauge = New XRGauge() With {
    .ViewType = DashboardGaugeType.Linear,
    .ViewStyle = DashboardGaugeStyle.Horizontal,
    .ViewTheme = DashboardGaugeTheme.FlatDark,
    .Minimum = 0,
    .Maximum = 50
}

' Specify an expression for the gauge's "ActualValue" property.
gauge.ExpressionBindings.Add(New ExpressionBinding("ActualValue", "[UnitPrice]"))

Implements

IScriptable

Inheritance

Object MarshalByRefObject Component XRControl XRGauge

See Also

XRGauge Members

Add Controls to a Report

Use Report Controls

DevExpress.XtraReports.UI Namespace