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.
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.
In the designer that opens, switch to the Data Bindings page and select the Add Project Data Source… option.
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.
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.
To proceed, click Next.
Click Next on the following page to save the created connection string to the configuration file.
Now, choose the tables containing information required for the gauge. Select the Products -> UnitPrice table as shown below and click Finish.
Run the application to see the result.
To learn more about Gauge Control data-binding, see Data Binding.