如何使用Report Viewer触发DrillThrough

时间:2014-10-27 15:08:17

标签: c# wpf

我在我的WPF应用程序中使用ReportViewer。

我正在尝试在我的c#代码中触发一个函数,该按钮将在ReportViewer上。

我想知道如何触发DrillThrough?

void DemoDrillThroughEventHandler(object sender, DrillthroughEventArgs e)
{
    MessageBox.Show("Drillthrough worked");
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    try
    {
        this._reportViewer.Drillthrough += new DrillthroughEventHandler(DemoDrillThroughEventHandler);
        this._reportViewer.Reset();

        ....
        this._reportViewer.LocalReport.Refresh();
        this._reportViewer.RefreshReport();
    }
}

1 个答案:

答案 0 :(得分:0)

有时会有一种方法可以提升事件(OnSomething,例如,在winforms中有Button.PerformClick)。否则,您可以将事件处理程序中的代码放在单独的函数中并直接调用它。

最简单的解决方案

DemoDrillThroughEventHandler(this._reportViewer, new DrillthroughEventArgs());

甚至(取决于内部发生的事情)

DemoDrillThroughEventHandler(null, null);
相关问题