How To: Create a Digital Gauge (Runtime)

  • 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:

CreateDigitalGauge_ex

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;