我是水晶报告的新手,并试图在 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;
}
它没有显示任何错误或任何东西。先感谢您。