Back to Devexpress

Display Data from WinForms Controls in a Chart

windowsforms-119224-controls-and-libraries-chart-control-provide-data-display-data-from-winforms-controls-in-chart.md

latest3.2 KB
Original Source

Display Data from WinForms Controls in a Chart

  • May 27, 2025
  • 2 minutes to read

Tip

Use the DevExpress BI Dashboard to build cross-platform data visualization UIs with Charts, Grids, Maps, Pivot Grids, Range Selectors, and other visualization components. BI Dashboard ships as part of the DevExpress Universal Subscription.

Get Started with the DevExpress Dashboard

The ChartControl can display data from the following controls:

Bind Chart at Design Time

  1. Select the Chart Control.

  2. Open the Smart Tag menu and click Data Source Wizard :

  3. In the Wizard, select the Data Control Rows technology and the source control. Click Next :

  4. Select the type of rows to visualize (for example, a GridView):

  5. Map the following chart members to data fields:

  6. Click Finish and run the project. The following screenshot shows the ChartControl that visualizes grid data:

Note

The Data Source Wizard automatically adds a ControlRowSource component and binds it to the ChartControl.DataSource property. The ControlRowSource component is not available in the Toolbox.

Bind Chart at Runtime

  1. Create a new instance of the ControlRowSource class.
  2. Initialize Control and ControlRows properties.
  3. Assign the ControlRowSource object to the ChartControl.DataSource property.
  4. Map the Chart Control’s SeriesDataMember, ArgumentDataMember, and ValueDataMembers properties to data fields.
csharp
// Bind the chart to visible rows in the grid.
chartControl.DataSource = new DevExpress.Data.Controls.ControlRowSource() {
    Control = mainView,
    ControlRows = DevExpress.Data.Controls.ControlRows.Visible
};

// Group series by 'State'.
chartControl.SeriesDataMember = "State";

// Set argument and value bindings.
chartControl.SeriesTemplate.ArgumentDataMember = "Category";
chartControl.SeriesTemplate.ValueDataMembers.AddRange("Revenue");
vb
' Bind the chart to visible rows in the grid.
chartControl.DataSource = New DevExpress.Data.Controls.ControlRowSource() With {
    .Control = mainView,
    .ControlRows = DevExpress.Data.Controls.ControlRows.Visible
}

' Group series by 'State'.
chartControl.SeriesDataMember = "State"

' Set argument and value bindings.
chartControl.SeriesTemplate.ArgumentDataMember = "Category"
chartControl.SeriesTemplate.ValueDataMembers.AddRange(New String() {"Revenue"})

View Example