Page tree
Skip to end of metadata
Go to start of metadata

你可以通过代码在Form_Load事件中设定SSRS文件的位置。
参见SSRSDocumentSource快速入门学习如何使用设计器设定文件的位置。
代码

C#

c1SSRSDocumentSource1.DocumentLocation = new
C1.Win.C1Document.SSRSReportLocation("http://ssrs.abc.com/ReportServer", "/Adventure
Works/Sales");

VB

c1SSRSDocumentSource1.DocumentLocation = New
C1.Win.C1Document.SSRSReportLocation("http://ssrs.abc.com/ReportServer", "/Adventure
Works/Sales")


4.1、显示文件的状态和页数

该章节描述如何使用C1SsrsDocumentSource组件的PageCount 和 State属性来显示文件源的状态以及已经产生的页数。如快速入门所示的创建一个应用程序然后完成下面几个步骤。

在设计器中

  1. 在窗体中放置两个label。
  2. 设定第一个label的Name属性为tbReport。
  3. 设定第二个label的Name属性为tbState。
  4. 设定第一个label的Text属性为Report:None。这个标签将显示报表的位置。
  5. 设定第二个label的Text属性为State:Unknown。这个标签将显示报表的状态和产生的页的页数。

在代码中在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

你完成了什么当运行你的项目时,注意你放置在窗体上的标签显示了报表的位置,状态和已经生成的页面的页数。

  • No labels