我是水晶报告的新手,并试图在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;
}
没有显示任何错误或任何内容。 提前谢谢。
答案 0 :(得分:0)
您正在使用 FirstCrystalReport ,我无法理解 使用下面的代码将有效。
FirstCrystalReport report = new FirstCrystalReport();
report.SetDataSource(源);
var vwindow = new viewerWindow();
vwindow.reportViewer.ViewerCore.ReportSource = report;
viewerWindow.ShowDialog();