1

我有一份显示测试集合的报告。测试报告实际上是另一个 xtrareport,在收集报告中显示为子报告。在这些测试报告中可以有多个子测试和。对于每个子测试,都有一个在脚本中创建的图表。这是为子测试创建图表的脚本:

private void xrChart1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) 
{
    XRChart chrt = (XRChart)sender;
    XYDiagram axis = (XYDiagram)chrt.Diagram;
    if (chrt.Series.Count > 0)
    {
        while (chrt.Series[0].View is ScatterLineSeriesView)
        {
            chrt.Series.RemoveAt(0);
        }
    }
    Series standardSeries = chrt.Series[0];
    Series allBottleSeries = chrt.Series[1];
      var curColVal = this.DetailReport1.GetCurrentColumnValue("ShowCurve");
      if (curColVal == null)
    {
        return;
    }
    chrt.BeginInit();
    chrt.Visible = (bool)curColVal;
    if (chrt.Visible)
    {
        List<TSegment> segments = (List<TSegment>)this.DetailReport1.GetCurrentColumnValue("Segments");
        if (segments != null)
        {
            foreach (TSegment segment in segments)
            {
                Series tempSeries = new Series();
                ScatterLineSeriesView tempscatterLineSeriesView = new ScatterLineSeriesView();
                tempscatterLineSeriesView.LineMarkerOptions.BorderVisible = false;
                tempscatterLineSeriesView.MarkerVisibility = DefaultBoolean.False;
                tempscatterLineSeriesView.LineStyle.Thickness = segment.Thickness;
                tempscatterLineSeriesView.Color = segment.SegmentColor;
                tempSeries.LabelsVisibility = DefaultBoolean.False;
                tempSeries.View = tempscatterLineSeriesView;
                tempSeries.ShowInLegend = false;
                tempSeries.ArgumentDataMember = "X";
                tempSeries.ArgumentScaleType = ScaleType.Numerical;
                tempSeries.ValueDataMembersSerializable = "Y";
                tempSeries.DataSource = segment.Points;
                chrt.Series.Insert(0, tempSeries);
            }
        }
        standardSeries.ValueDataMembers[0] = "ODValue";
        standardSeries.ArgumentDataMember = "ConcentrationValue";
        standardSeries.DataSource = this.DetailReport1.GetCurrentColumnValue("Standards");
        allBottleSeries.ValueDataMembers[0] = "Y";
        allBottleSeries.ArgumentDataMember = "X";
        allBottleSeries.DataSource = this.DetailReport1.GetCurrentColumnValue("BottlePoints");
        axis.AxisX.Logarithmic = (bool)this.DetailReport1.GetCurrentColumnValue("XPlotIsLog");
        axis.AxisX.LogarithmicBase = (double)this.DetailReport1.GetCurrentColumnValue("LogarithmicBase");
        axis.AxisX.Title.Text = (string)this.DetailReport1.GetCurrentColumnValue("UnitsOfConcentration");
        axis.AxisX.Label.NumericOptions.Format = NumericFormat.Number;
        axis.AxisX.Label.NumericOptions.Precision = (int)this.DetailReport1.GetCurrentColumnValue("NumberOfDigitsInResults");
        axis.AxisY.Label.NumericOptions.Format = NumericFormat.Number;
        axis.AxisY.Label.NumericOptions.Precision = (int)this.DetailReport1.GetCurrentColumnValue("NumberOfDigitsInMeasuredValues");
        axis.AxisY.Logarithmic = (bool)this.DetailReport1.GetCurrentColumnValue("YPlotIsLog");
        axis.AxisY.LogarithmicBase = axis.AxisX.LogarithmicBase;
            axis.AxisY.Title.Text = (string)this.DetailReport1.GetCurrentColumnValue("UnitsOfStandardsInput");
        axis.AxisY.WholeRange.AlwaysShowZeroLevel = !(bool)this.DetailReport1.GetCurrentColumnValue("ODAxisShouldNotStartAtZero");
    }
    chrt.EndInit();

}

现在,如果我单独查看此子报告,报告将正确显示。不同的子测试有不同的图表。

问题是当我显示收集报告时,子报告显示错误。所有的图表都没有什么不同。最后一个子测试的图表一直显示。

此脚本用于设置子报表的报表源:

private void Detail1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) 
{
    ((XRSubreport)sender).ReportSource = this.DetailReport.GetCurrentRow() as XtraReport;
}

有人知道这里发生了什么吗?

4

1 回答 1

0

找到了这个问题的答案。它实际上与脚本无关。我们将集合报告绑定到的对象有一个名为 TestXtrareports 的属性,它是一个 XtraReport 列表。当我们创建这个对象时,我们在 XtraReport 上调用了 CreateDocument,然后将它添加到 TestXtraReports。这就是导致此错误的原因。只需删除 TestXtraReports 中 XtraReports 的 createDocument 语句即可解决。仍然在收集报告上调用 CreateDocument。

于 2015-09-04T12:43:14.340 回答