2011-08-12 86 views

回答

3

您可以使用打印機選擇製作自己的表單。使用System.Drawing.Printing.PrinterSettings

foreach (string s in PrinterSettings.InstalledPrinters) 
    { 
     liste.Items.Add(s); 
    } 

然後你就可以用這個代碼創建報表(請確保您的報告生成操作設置爲嵌入的資源)

LocalReport report = new LocalReport(); 
report.DataSources.Add(new ReportDataSource("your data source name",DataTableGoesHere); 
     report.ReportEmbeddedResource = "YourNameSpace.YourReportName.rdlc"; 

然後綁定安裝打印機的組合框或東西請按照這些說明打印本地報告: http://blogs.msdn.com/b/brianhartman/archive/2009/02/27/manually-printing-a-report.aspx

確保您以某種方式將打印機的變量傳遞給打印類。打印機名稱必須設置:

printDoc.PrinterSettings.PrinterName = "installed printer chosen from combo goes here";