我有一個應用程序,它有兩個選項,用於打印報表或預覽報表。我有以下代碼來打印報告 -如何在C#中執行打印預覽Crystal Reports 2010
FCPMS.Reports.rptPanelStudy crtrptPanelStudy = new FCPMS.Reports.rptPanelStudy();
crtrptPanelStudy.FileName = tReportFileName; -(refers to the file location on the computer)
crtrptPanelStudy.DataDefinition.FormulaFields["PANELNUM"].Text = "'5'";
foreach (Table tblTable in crtrptPanelStudy.Database.Tables)
{
tiInfo = tblTable.LogOnInfo;
tiInfo.ConnectionInfo = ciConnection;
tblTable.ApplyLogOnInfo(tiInfo);
}
crtrptPanelStudy.PrintToPrinter(1, false, 0, 0);
這可正常工作並打印報告。但是,我無法找到類似的代碼來簡單地使用此報告打開打印機預覽。有誰知道我該怎麼做?我只需要打印機預覽即可在沒有報告實際打印的情況下彈出。任何幫助,將不勝感激。
我還試圖用打印對話框 -
PrintPreviewDialog printpreview = new PrintPreviewDialog();
printpreview.Document = crtrptFlowRangeSummary;
printpreview.ShowDialog();
,但得到的第二行此錯誤
錯誤35無法隱式轉換類型
FCPMS.Reports.rptFlowRangeSummary
到System.Drawing.Printing.PrintDocument
有你看着PrintPreviewDialog上? http://msdn.microsoft.com/en-us/library/system.windows.forms.printpreviewdialog.aspx – MethodMan 2012-08-17 13:17:53
是的,但沒有奏效。詳情請參閱我編輯的問題。 – 2012-08-17 13:26:35
您需要CrystalReportPrintPreviewForm – MethodMan 2012-08-17 13:32:37