簡體   English   中英

如何在沒有數據庫的情況下生成水晶報表僅顯示用戶填寫的表格數據在c#表單應用程序中

[英]how to generate crystal Report without Database Only for showing Form Data filled by User In c# form Application

我想在不使用任何數據庫的情況下創建一個水晶報告我只想顯示用戶輸入的文本。 見下圖: 在此輸入圖像描述

我是新手在c#表單應用程序中

假設你是C#; 在設計模式下在Crystal報表中創建所需的TextObjects(如果沒有Crystal許可證,則無法動態添加它)。 如果WinForm中有四個值,並且您希望這些值在Crystal Report中發布; 您將需要創建四個TextObjects。 執行此操作后,只需在按鈕單擊事件中鍵入以下代碼:

/*Initialize the Report Object*/
ReportDocument cryRpt = new ReportDocument();
/*Load the designed report*/
cryRpt.Load(Application.StartupPath + "\\MyReport.rpt");

/*initialize required TextObjects*/
/*SYNTAX :
TextObject objectName = (TextObject)cryRpt.ReportDefinition.Sections["name of report section"].ReportObjects["Name of textobject"];

*/
TextObject txt1 = (TextObject)cryRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextObject1"];


TextObject txt2 = (TextObject)cryRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextObject2"];



/*Pass the text value from WinForm TextBox to Crystal Report TextObject*/
txt1.Text = textbox1.Text;
txt2.Text = textbox2.Text;



/*Create a Form and display the crystal report*/
Form frm = new Form();
frm.Height = 800;
frm.Width = 600;

CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;


crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();

frm.Controls.Add(crystalReportViewer1);
frm.ShowDialog();

那都是:) / *快樂編碼:) * /

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM