3

我有一个 Crystal Reports 13 wpf 控件,我正在加载一个报表和数据集中的数据:

ReportDocument report = new ReportDocument();
if (report != null)
{
  report.Load(ReportFileName);
  report.SetDataSource(DataSet);
  reportViewer.ViewerCore.ReportSource = report;
}

为了知道控件何时完成渲染,我可以处理什么事件?查看器导出:

public event PageMouseEventHandler ClickPage;
public event PageMouseEventHandler DoubleClickPage;
public event DrillEventHandler Drill;
public event DrillSubreportEventHandler DrillDownSubreport;
public event NavigateEventHandler Navigate;
public event RefreshEventHandler Refresh;
public event SearchEventHandler Search;
public event RoutedEventHandler SelectionChange;
public event RoutedEventHandler ViewChange;
public event ZoomEventHandler ViewZoom;

ViewerCore 仅导出:

public event ExceptionEventHandler Error;

这些似乎都不合理。我也曾短暂地使用过 ReportClientDocument。

4

2 回答 2

3

为后代:

DependencyPropertyDescriptor p = DependencyPropertyDescriptor.FromProperty(SAPBusinessObjects.WPF.Viewer.ViewerCore.TotalPageNumberProperty, typeof(SAPBusinessObjects.WPF.Viewer.ViewerCore));
p.AddValueChanged(reportViewer.ViewerCore, OnPageCountChanged);

由于在呈现该页面后正确更新了 TotalPageNumber 属性...

private void OnPageCountChanged(object sender, EventArgs e)
{
   //do whats needed
}

您知道控件何时完成渲染。

于 2012-12-05T19:57:47.583 回答
2

在 Crystal Reports 13 中有一个 PageChanged 事件,由于某种原因没有在 UI 中公开(它有一个Browsable(false)属性)。我需要缩放报告,而这个事件是我能做到的唯一非 hacky 方式:就做

viewer.PageChanged += Viewer_PageChanged;

在表单构造函数中,然后添加

private void Viewer_PageChanged(object sender, EventArgs e)
{
    viewer.Zoom(2);
}

到您的私有方法。(viewerCrystalReportViewer表单上的组件。)

于 2016-04-12T11:01:53.513 回答