Devexpress:如何将控件添加到XtraReport中的另一个控件下面

时间:2016-01-26 23:15:12

标签: c# devexpress xtrareport devexpress-windows-ui

我使用XtraReport来显示我的报告。我想将我的图表添加到另一个下面。以下是我在XtraReport添加新图表的代码。

foreach (Control viewControl in Panel.Controls)
{
    if (viewControl.GetType() == typeof(ChartControl))
    {
        XRChart chart = new XRChart();

        ChartControl chartControl = viewControl as ChartControl;

        if (chartControl != null)
        {
            foreach (ISeries series in chartControl.Series)
            {
                Series s = new Series(series.Name, ViewType.Bar);
                s.Points.Add(
                    new SeriesPoint(
                        series.Points.First().UserArgument.ToString(), 
                        series.Points.First().UserValues.FirstOrDefault()
                    )
                );
                chart.Series.Add(s);
            }

            myReport.Detail.Controls.Add(chart);
        }
    }
}

我找不到在两个XtraChart之间插入断行的方法。

1 个答案:

答案 0 :(得分:1)

您需要使用XRControl.TopF属性缩进图表。您可以从上一个图表的XRControl.BottomF属性获得缩进的值 这是一个例子:

float topF = 0;

foreach (Control viewControl in Panel.Controls)
{    
    var chartControl = viewControl as ChartControl;

    if (chartControl == null)
        continue;

    var chart = new XRChart();

    foreach (ISeries series in chartControl.Series)
    {
        var s = new Series(series.Name, ViewType.Bar);
        s.Points.Add(
            new SeriesPoint(
                series.Points.First().UserArgument.ToString(), 
                series.Points.First().UserValues.FirstOrDefault()
            )
        );
        chart.Series.Add(s);
    }

    chart.TopF = topF; // Indent chart.
    topF = chart.BottomF; // Set next value to the topF.

    myReport.Detail.Controls.Add(chart);    
}