我试着Print
去List of objects
。Crystal Report
所以我创建了一个 WPF 窗口,如下所示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace Winlease.UI
{
/// <summary>
/// Logique d'interaction pour EcheancierPrint.xaml
/// </summary>
public partial class EcheancierPrint : Window
{
List<T> ListToPrint = null;
public EcheancierPrint(List<T> lst) : base()
{
ListToPrint = lst;
}
public EcheancierPrint()
{
InitializeComponent();
}
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
ReportDocument rd = new ReportDocument();
rd.Load("../../Echeancier.rpt");
rd.SetDataSource(ListToPrint);
}
}
}
这个窗口是从另一个窗口中按钮的 Click 事件处理程序调用的,这里的代码:
private void cmdPrint_Click(object sender, RoutedEventArgs e)
{
EcheancierPrint pe = new EcheancierPrint(echeancier);
}
Echeancier
是一个List of Object
叫Echeance
。类型“T”和方法InitializeComponent变为红色下划线,并且不被 WPF 编译器接受。指令的相同行为:
EcheancierPrint pe = new EcheancierPrint(echeancier);