Skip to main content

How to: Bind Series to Data and Display Them In Separate Panes (Runtime Sample)

  • 3 minutes to read

This example demonstrates how to display a chart’s series in separate panes.

For this example to work correctly, do the following.

  1. Start MS Visual Studio, and create a new Windows Forms Application, or open an existing one.
  2. Include all necessary assemblies to the References list of your project.
  3. Open the Solution Explorer window (e.g. by pressing CTRL+ALT+L), right-click the WindowsApplication1 item and in the invoked menu, point to Add and click Existing Item…. Then, locate the gsp.mdb file (it is shipped with XtraCharts suite and located in the directory, where you installed DevExpress demos) and click Add. In the displayed dialog, select the GSP table of this database.

    A dataset (named gspDataSet) is automatically created after performing the above steps.

  4. Drop a button onto the form and add the following code to the Button1.Click event handler.

View Example

using System;
using DevExpress.XtraCharts;
using DevExpress.XtraEditors;

namespace TwoBoundSeriesInPanes {
    public partial class MainForm : XtraForm {
        public MainForm() {
            // This line of code is generated by Data Source Configuration Wizard

        private void OnFormLoad(object sender, EventArgs e)
            Series year2003Series = new Series();
            year2003Series.Name = "2003";
            year2003Series.ArgumentDataMember = "Region";
            year2003Series.ValueDataMembers[0] = "GSP";
            year2003Series.FilterString = @"[Year] == 2003";

            Series year2004Series = new Series();
            year2004Series.Name = "2004";
            year2004Series.ArgumentDataMember = "Region";
            year2004Series.ValueDataMembers[0] = "GSP";
            year2004Series.FilterString = @"[Year] == 2004";

            chartControl.Series.AddRange(year2003Series, year2004Series);

            XYDiagram diagram = (XYDiagram)chartControl.Diagram;
            XYDiagramPane secondPane = new XYDiagramPane("Second Pane");

            Legend secondLegend = new Legend("Second Legend") {
                DockTarget = secondPane,
                AlignmentHorizontal = LegendAlignmentHorizontal.Right,
                AlignmentVertical = LegendAlignmentVertical.Top

            XYDiagramSeriesViewBase xyView = (XYDiagramSeriesViewBase)year2004Series.View;
            year2004Series.Legend = secondLegend;
            xyView.Pane = secondPane;
See Also