Search code examples
c#devexpressdevexpress-windows-ui

DevEx XtraGrid display as chart


I have a DevEx Xtragrid component displaying multiple sets of numeric data. I would like to show this as multiple series on a line chart. I want to toggle between displaying the data in a grid and on a chart at the click of a button.

Is there an 'easy' way in DevEx to accomplish this?


Solution

  • You can create the specific UserControls/Views based on grid and chart and then dock both into the single container(Panel). To toggle display mode you can use the following code:

    viewGrid.Dock = Dock.Fill;
    viewGrid.Visible = true; // show grid initially
    viewGrid.Parent = pnlContainer;
    viewChart.Dock = Dock.Fill;
    viewChart.Visible = false; // hide chart initially
    viewChart.Parent = pnlContainer;
    // ...
    void btn_ToggleView(object sender, EventArgs e){
        bool showChart = viewGrid.Visible;
        viewGrid.Visible = !showChart;
        viewChart.Visible = showChart;
    }
    

    P.S. DevExpress also provides the Navigation Frame container that hosts multiple pages and allows only one of them to be displayed at a time.