Skip to main content

How To: Bind a Gauge Control to a Data Source

  • 2 minutes to read

This sample shows how to data-bind the text of a digital gauge to a field in the NWind database at design time.

At design time, you can data-bind the DigitalGauge.Text property to the NWind database via the Properties grid or the gauge’s designer.

To bind via the Properties grid, locate the DigitalGauge.Text property in the DataBindings section. Then, open the dropdown for this property and select the data source you would like to bind to the property.

DataBinding_DigitalGaugeText

Let’s consider how to bind the text of a digital gauge to the NWind database via the gauge’s designer in more detail.

To bind to a property via the gauge’s designer, first open the designer by selecting a gauge object on the form and selecting the Run Designer option from the gauge’s tag menu.

DataBinding_DigitalGauge_RunDesigner

  • In the designer that opens, switch to the Data Bindings page and select the Add Project Data Source… option.

    DataBindingDesigner

    The Data Source Configuration Wizard appears. It allows you to select a data source.

  • In the Wizard’s first page, select the Database icon and click Next.

    Gauge Binding- DataBase source

  • On the Choose your Data Connection page, click New Connection and specify the path (C:\Users\Public\Documents\DevExpress Demos 24.1\Components\Data\nwind.mdb) to the NWind database file (leave the Password option blank). Then, you may use the Test Connection option to test data source availability.

    Gauge Binding-Choose Connection

    To proceed, click Next.

  • Click Next on the following page to save the created connection string to the configuration file.

    Gauge Binding - Save the Connection string

  • Now, choose the tables containing information required for the gauge. Select the Products -> UnitPrice table as shown below and click Finish.

    Gauge Binding - Choose Database Objects

  • Run the application to see the result.

    Binding - Run the application

To learn more about Gauge Control data-binding, see Data Binding.