[所见非所得2]控制水晶报表的部分元素不打印
2008-11-22 14:49
369 查看
在前文<[所见非所得]使用参数控制水晶报表的部分元素不打印>中,使用了参数结合编程的方法实现。
CSDN论坛上的网友提供了另外一种更好的方法
http://topic.csdn.net/u/20081103/08/4aa67c3a-185b-4f96-8197-1fda53e6c0aa.html?seed=1144679551
方法重点:显示与打印分离,程序中直接设置对象的抑制显示属性。然后打印。
核心语句:
myReport.ReportDefinition.ReportObjects["Text1"].ObjectFormat.EnableSuppress=true;
模板中不再需要使用参数和公式,直接操作即可。以 WinForm 为例,核心代码为
Public Class Form2
Private myReport As New ReportDocument
Private Sub ConfigureCrystalReports()
Dim reportPath As String = Application.StartupPath & "/" & "crystalreport2.rpt"
myReport.Load(reportPath)
CrystalReportViewer1.ReportSource = myReport
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConfigureCrystalReports()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
myReport.ReportDefinition.ReportObjects("Text8").ObjectFormat.EnableSuppress = True
myReport.ReportDefinition.ReportObjects("Subreport1").ObjectFormat.EnableSuppress = True
myReport.PrintOptions.PrinterName = "Microsoft Office Document Image Writer"
myReport.PrintToPrinter(1, False, 1, 99)
End Sub
End Class
CSDN论坛上的网友提供了另外一种更好的方法
http://topic.csdn.net/u/20081103/08/4aa67c3a-185b-4f96-8197-1fda53e6c0aa.html?seed=1144679551
方法重点:显示与打印分离,程序中直接设置对象的抑制显示属性。然后打印。
核心语句:
myReport.ReportDefinition.ReportObjects["Text1"].ObjectFormat.EnableSuppress=true;
模板中不再需要使用参数和公式,直接操作即可。以 WinForm 为例,核心代码为
Public Class Form2
Private myReport As New ReportDocument
Private Sub ConfigureCrystalReports()
Dim reportPath As String = Application.StartupPath & "/" & "crystalreport2.rpt"
myReport.Load(reportPath)
CrystalReportViewer1.ReportSource = myReport
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConfigureCrystalReports()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
myReport.ReportDefinition.ReportObjects("Text8").ObjectFormat.EnableSuppress = True
myReport.ReportDefinition.ReportObjects("Subreport1").ObjectFormat.EnableSuppress = True
myReport.PrintOptions.PrinterName = "Microsoft Office Document Image Writer"
myReport.PrintToPrinter(1, False, 1, 99)
End Sub
End Class
相关文章推荐
- [所见非所得]使用参数控制水晶报表的部分元素不打印
- [所见非所得]使用参数控制水晶报表的部分元素不打印
- [所见非所得2]控制水晶报表的部分元素不打印
- [所见非所得2]控制水晶报表的部分元素不打印
- 使用参数控制水晶报表的部分元素不打印
- 水晶报表打印知识---编程控制打印
- php部分:网页中报表的打印,并用CSS样式控制打印的部分;
- 水晶报表打印知识---编程控制打印
- 答静静:动态更改水晶报表部分数据的背景颜色(VB.Net)
- 报表支持部分外部CSS样式表控制新增功能
- 水晶报表直接打印 不用转为PDF打印
- 水晶报表 打印 主及子报表的数据源绑定
- [水晶报表]不显示报表直接打印
- [水晶报表]RECORDNUMBER应用之控制每页显示行数及隔行换色
- 水晶报表ActiveX控件打印
- [水晶报表小技巧-开发-3]ASP.Net中使用水晶报表10的打印功能
- 水晶报表 自定义打印纸张
- C#之二十三 打印和水晶报表
- winform 水晶报表 更改 打印队列 中的 文档名 (Set Crystal Reports Document Name In Printer Queue)
- 折腾 VS2008 + ReportViewer + CrystalReports + PrintControl.cab 实现水晶报表本地打印