Back to Devexpress

How To: Create a Digital Gauge (Runtime)

windowsforms-113857-controls-and-libraries-gauges-examples-how-to-create-a-digital-gauge-runtime.md

latest2.6 KB
Original Source

How To: Create a Digital Gauge (Runtime)

  • Nov 13, 2018
  • 2 minutes to read

The following example shows how to create a digital gauge.

In the example a digital gauge is created using the DevExpress.XtraGauges.Win.GaugeControlBase.AddDigitalGauge method. Then, a background layer is added to the gauge via the DigitalGauge.AddBackgroundLayer method. The text foreground color is specified via the DigitalGauge.AppearanceOn property.

The result is displayed below:

csharp
using DevExpress.XtraGauges.Win;
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraGauges.Core.Base;
using DevExpress.XtraGauges.Win.Gauges.Digital;

GaugeControl gc = new GaugeControl();
// Add a digital gauge.
DigitalGauge digitalGauge = gc.AddDigitalGauge();          
// The text to be displayed.
digitalGauge.Text = "Gauge Control";
// The number of digits.
digitalGauge.DigitCount = 14;
// Use 14 segment display mode.
digitalGauge.DisplayMode = DigitalGaugeDisplayMode.FourteenSegment;
// Add a background layer and set its painting style.
DigitalBackgroundLayerComponent background = digitalGauge.AddBackgroundLayer();
background.ShapeType = DigitalBackgroundShapeSetType.Style2;
// Set the color of digits.
digitalGauge.AppearanceOn.ContentBrush = new SolidBrushObject(Color.Red);
// Add the gauge control to the form.
gc.Size = new Size(250, 100);
gc.Parent = this;
vb
Imports DevExpress.XtraGauges.Win
Imports DevExpress.XtraGauges.Core.Model
Imports DevExpress.XtraGauges.Core.Base
Imports DevExpress.XtraGauges.Win.Gauges.Digital

Private gc As GaugeControl = New GaugeControl()
' Add a digital gauge.
Private digitalGauge As DigitalGauge = gc.AddDigitalGauge()
' The text to be displayed.
Private digitalGauge.Text = "Gauge Control"
' The number of digits.
Private digitalGauge.DigitCount = 14
' Use 14 segment display mode.
Private digitalGauge.DisplayMode = DigitalGaugeDisplayMode.FourteenSegment
' Add a background layer and set its painting style.
Private background As DigitalBackgroundLayerComponent = digitalGauge.AddBackgroundLayer()
Private background.ShapeType = DigitalBackgroundShapeSetType.Style2
' Set the color of digits.
Private digitalGauge.AppearanceOn.ContentBrush = New SolidBrushObject(Color.Red)
' Add the gauge control to the form.
Private gc.Size = New Size(250, 100)
Private gc.Parent = Me