How to: Bind a Gauge Dashboard Item to Data in Code

  • 2 minutes to read

The following example demonstrates how to bind a Gauge dashboard item to data in code.

View Example: How to Bind a Gauge Dashboard Item to Data at Runtime

using System;
using System.Windows.Forms;
using DevExpress.DashboardCommon;

namespace Dashboard_CreateGauges {
    public partial class Form1 : Form {
        public Form1() {
        private GaugeDashboardItem CreateGauges(DashboardObjectDataSource dataSource) {

            GaugeDashboardItem gauges = new GaugeDashboardItem();
            gauges.ViewType = GaugeViewType.CircularHalf;
            gauges.DataSource = dataSource;

            Gauge gauge = new Gauge();
            gauge.ActualValue = new Measure("Extended Price", SummaryType.Sum);

            gauges.SeriesDimensions.Add(new Dimension("Sales Person"));

            return gauges;
        private void Form1_Load(object sender, EventArgs e) {
            Dashboard dashboard = new Dashboard();
            DashboardObjectDataSource dataSource = new DashboardObjectDataSource();

            GaugeDashboardItem gauges = CreateGauges(dataSource);

            dashboardViewer1.AsyncDataLoading += (s, ev) => {
                ev.Data = new nwindDataSetTableAdapters.SalesPersonTableAdapter().GetData();
            dashboardViewer1.Dashboard = dashboard;
See Also