Skip to main content

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Display Data from WinForms Controls in a Chart

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

    Smart Tag Menu - WinForms Chart Control, DevExpress

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

    Data Source Wizard - WinForms Chart Control, DevExpress

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

    Select Row Type - Chart Data Source Wizard, DevExpress

  5. Map the following chart members to data fields:

    • Series Member
    • Argument Member
    • Value Member

    Map to Data Fields - Chart Data Source Wizard, DevExpress

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

    WinForms Chart Control Displays Data from the Data Grid, DevExpress

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.
// 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");

View Example