我有一個C#應用程序,在窗體中有一個Crystal Report Viewer。我調用該表單並傳遞一個值,我用它來更新與Crystal Report關聯的參數字段,以便只顯示特定的記錄。打印不顯示打印選項對話框Crystal Report Viewer在我的C#中
這一切都很好,我可以調用Viewers PrintReport方法來打印報告,而無需操作員干預。
CrystalForm fs = new CrystalForm();
fs.SetCrystalOrderNumParameter(ItemID);
public partial class CrystalForm : Form
{
public CrystalForm()
{
InitializeComponent();
}
public void SetCrystalOrderNumParameter(string ItemID)
{
ParameterFields paramFields = new ParameterFields();
ParameterField paramField = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "ItemID";
paramDiscreteValue.Value = ItemID;
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
crystalReportViewer1.ParameterFieldInfo = paramFields;
crystalReportViewer1.PrintReport();
}
}
我遇到的問題是,我希望能夠以一個值傳遞給水晶報表,以便它使用這個#,以確定如何報告的多個副本應打印。
有沒有辦法使用Crystal Report Viewer來做到這一點?
非常感謝您的幫助。
布蘭登感謝您回覆我的問題。我將Crystal Report與CrystalReportView相關聯的方式是在將CrystalReportView組件拖動到我的窗體後,單擊窗體右上角出現的箭頭,然後使用屬性對話框顯示允許我選擇要使用的外部Crystal Report。 –
嗯,如果您在SetCrystalOrderNumParameter函數中設置斷點,並檢查報表查看器的ReportSource屬性,它是否包含ReportDocument對象?也許你可以從源文件檢索文檔,只需要調用PrintToPrinter? –
我不熟悉使用visual studio designer來設置/顯示水晶報表。對不起,我不能在這方面得到更多的幫助。 –