0

我是水晶报告的新手,并试图在 wpf 中练习它,但报告没有显示任何数据。

我的代码在这里:

<Window x:Class="CrystalReportDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="800" Width="900" xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" Loaded="Window_Loaded">
<Grid>
<my:CrystalReportsViewer HorizontalAlignment="Left" Margin="127,73,0,0" 
Name="crystalReportsViewer1" VerticalAlignment="Top" />
</Grid>
</Window>

后面的代码:

private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        FirstCrystalReport report = new FirstCrystalReport();
        report.Load("DemoCrystalReport.rpt");
        report.SetDataSource((from item in dataContext.tokens
                              select new
                              {
                                  item.nvcraddress,
                                  item.bgIntcontact_no,
                                  item.dtDateOfToken,
                                  item.vcrpan_no,
                                  item.vcrplate_no,
                                  item.token_id,
                                  item.nvcrNameOfCustomer,
                                  item.nvcrMiddleName,
                                  item.nvcrLastName
                              }).ToList());
        crystalReportsViewer1.ViewerCore.ReportSource = report;
}

它没有显示任何错误或任何东西。先感谢您。

4

1 回答 1

0

You are using FirstCrystalReport , i am unable to understand.
use below code will work.

FirstCrystalReport report =new FirstCrystalReport();

report.SetDataSource(source);

var vwindow= new viewerWindow();

vwindow.reportViewer.ViewerCore.ReportSource = report ;

viewerWindow.ShowDialog();

于 2013-09-30T13:02:43.983 回答