该章节描述如何使用C1SsrsDocumentSource组件的PageCount 和 State属性来显示文件源的状态以及已经产生的页数。如快速入门所示的创建一个应用程序然后完成下面几个步骤。
在Form_Load的事件中添加下面的代码,这样就可以将报表的位置,状态和页数显示在标签上。
C# |
拷贝代码
|
---|---|
SSRSReportLocation rl = c1SSRSDocumentSource1.DocumentLocation as SSRSReportLocation; if (rl != null) tbReport.Text = C1.Win.C1Ssrs.ReportSession.Combine(rl.ReportServer, rl.ReportPath); else tbReport.Text = "None"; switch (c1SSRSDocumentSource1.State) { case C1DocumentSourceState.Generated: case C1DocumentSourceState.GeneratedWithErrors: case C1DocumentSourceState.Generating: tbState.Text = string.Format("{0}, Pages: {1}", c1SSRSDocumentSource1.State, c1SSRSDocumentSource1.PageCount); break; default: tbState.Text = c1SSRSDocumentSource1.State.ToString(); break; } |
VB |
拷贝代码
|
---|---|
Dim rl As SSRSReportLocation = TryCast(c1SSRSDocumentSource1.DocumentLocation, SSRSReportLocation) If rl IsNot Nothing Then tbReport.Text = C1.Win.C1Ssrs.ReportSession.Combine(rl.ReportServer, rl.ReportPath) Else tbReport.Text = "None" End If Select Case c1SSRSDocumentSource1.State Case C1DocumentSourceState.Generated, C1DocumentSourceState.GeneratedWithErrors, C1DocumentSourceState.Generating tbState.Text = String.Format("{0}, Pages: {1}", c1SSRSDocumentSource1.State, c1SSRSDocumentSource1.PageCount) Exit Select Case Else tbState.Text = c1SSRSDocumentSource1.State.ToString() Exit Select End Select |
当运行你的项目时,注意你放置在窗体上的标签显示了报表的位置,状态和已经生成的页面的页数。