ActiveReports中自定义Winforms的Viewer 工具栏
ActiveReports中提供不同平台的报表浏览器来加载报表,而不同平台的报表浏览器功能也不一致,今天我们来学习如何定制Winforms Viewer控件。
预览效果:

核心代码:
C#
// C# private ToolStripButton tsbPrint = new System.Windows.Forms.ToolStripButton(); private void frmViewer_Load(object sender, EventArgs e)
{
System.Windows.Forms.ToolStrip toolStrip;
System.Windows.Forms.ToolStripItem orgItem;
System.Windows.Forms.ToolStripButton orgBtn = null; // Get the image from the standard Print button.
toolStrip = this.viewer1.Toolbar.ToolStrip;
orgItem = toolStrip.Items[2];
if (orgItem is System.Windows.Forms.ToolStripButton)
{
orgBtn = (System.Windows.Forms.ToolStripButton)orgItem;
} // Delete the standard Print button.
toolStrip.Items.RemoveAt(2); // Create a custom button to use in place of the standard Print button.
tsbPrint.Text = “HQ Print”;
tsbPrint.ToolTipText = “Print to the company headquarters main printer”;
tsbPrint.Image = orgBtn.Image;
tsbPrint.Enabled = false; // Set the event handler. (viewer.LoadCompleted can be set from the designer)
tsbPrint.Click += this.PrintButtonClick;
viewer1.LoadCompleted += this.viewer1_LoadCompleted; // Add the custom button to the toolbar.
toolStrip.Items.Insert(2, tsbPrint); // Instantiate the report.
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport(); // Load a report definition file.
rpt.Load(new System.IO.FileInfo(@”..\..\PageReport1.rdlx”));
GrapeCity.ActiveReports.Document.PageDocument pageDocument =
new GrapeCity.ActiveReports.Document.PageDocument(rpt); // Load the report into the viewer.
viewer1.LoadDocument(pageDocument);
} // The event to call when the report is loaded into the Viewer.
private void viewer1_LoadCompleted(object sender, EventArgs e)
{
// Enable the custom button.
tsbPrint.Enabled = true;
} // The event to call when the custom button is clicked.
private void PrintButtonClick(System.Object sender, System.EventArgs e)
{
// Perform print processing.
this.viewer1.Print(true, true, false);
}
VB.NET
‘ VB.NET Private tsbPrint As New System.Windows.Forms.ToolStripButton Private Sub frmViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim toolStrip As System.Windows.Forms.ToolStrip
Dim orgBtn As System.Windows.Forms.ToolStripButton = Nothing
Dim orgItem As System.Windows.Forms.ToolStripItem ‘ Get the image from the standard Print button.
toolStrip = Me.Viewer1.Toolbar.ToolStrip
orgItem = toolStrip.Items(2)
If TypeOf orgItem Is System.Windows.Forms.ToolStripButton Then
orgBtn = CType(orgItem, ToolStripButton)
End If ‘ Delete the standard Print button.
toolStrip.Items.RemoveAt(2) ‘ Create a custom button to use in place of the standard Print button.
tsbPrint.Text = “HQ Print”
tsbPrint.ToolTipText = “Print to the company headquarters main printer”
tsbPrint.Image = orgBtn.Image
tsbPrint.Enabled = False ‘ Set the event handler (Viewer.LoadCompleted can also be set in the designer)
AddHandler tsbPrint.Click, AddressOf Me.PrintButtonClick
AddHandler Viewer1.LoadCompleted, AddressOf Me.Viewer1_LoadCompleted ‘ Add the custom button to the toolbar.
toolStrip.Items.Insert(2, tsbPrint) ‘ Instantiate the report.
Dim rpt As New GrapeCity.ActiveReports.PageReport() ‘ Load a report definition file.
rpt.Load(New System.IO.FileInfo(“..\..\PageReport1.rdlx”))
Dim pageDocument As New GrapeCity.ActiveReports.Document.PageDocument(rpt) ‘ Load the report into the viewer.
viewer1.LoadDocument(pageDocument)
End Sub ‘ The event to call when the report loads in the Viewer.
Private Sub Viewer1_LoadCompleted(sender As Object, e As EventArgs)
‘ Enable the custom button.
tsbPrint.Enabled = True
End Sub ‘ The event to call when the custom button is clicked.
Private Sub PrintButtonClick(ByVal sender As Object, ByVal e As System.EventArgs)
‘ Perform print processing.
Me.Viewer1.Print(True, True, False)
End Sub
ActiveReports中自定义Winforms的Viewer 工具栏的更多相关文章
- ActiveReports中如何在后台导出运行时绑定数据源报表
ActiveReports支持运行时绑定数据源功能,这种绑定数据源方法使用较为普及,然而很多系统中都需要在后台导出报表文件,所以用户就很困惑,ActiveReports中如何在后台导出运行时绑定数据源 ...
- Access 2003 中自定义菜单栏
在Access中如何用自定义的菜单代替Access自带的菜单,现在做一个简单的介绍: 1.打开您做的Access数据库: 2.单击工具栏,选择“自定义…”: 3.在“自定义”窗口,单击“工具栏”选项卡 ...
- Html中自定义鼠标的形状
Html中自定义鼠标的形状 <html> <head> <title>自定义的鼠标形状</title> <meta http-equiv=&quo ...
- 教你一招:在PowerPoint中自定义可输入文本的占位符
日常生活中,当我们设计多媒体课件时,默认的版式其实已经够用了.但是,很多时候,我们需要更加个性一点,所以,我们需要自定义很多东西.本文介绍在PowerPoint中自定义可输入文本的占位符. 一.占位符 ...
- ActiveReports中如何控制页面的记录数
在 ActiveReports 中,可以固定报表每页显示的行数,当每页的数据不足固定的行数时,自动通过填补空白行来实现,当然这两种功能仅限于区域报表和页面报表中. 区域报表 在区域报表中,有很多方法来 ...
- android代码优化----ListView中自定义adapter的封装(ListView的模板写法)
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- 在Eclipse中自定义类似syso的快捷代码模板
sysout/syso syserr/ syse 点击菜单栏的“Window”->“Preferences”,打开“Preferences”对话框.在Preferences”对话框中点击“Jav ...
- 在.net桌面程序中自定义鼠标光标
有的时候,一个自定义的鼠标光标能给你的程序增色不少.本文这里介绍一下如何在.net桌面程序中自定义鼠标光标.由于.net的桌面程序分为WinForm和WPF两种,这里分别介绍一下. WinForm程序 ...
- .net中自定义过滤器对Response内容进行处理
原文:http://www.cnblogs.com/zgqys1980/archive/2008/09/02/1281895.html 代码DEMO:http://files.cnblogs.com/ ...
随机推荐
- Unable to execute dex: GC overhead limit exceeded
Android打包时下面的错误: Unable to execute dex: GC overhead limit exceeded GC overhead limit exceeded 解决的方法: ...
- 数据库助手类 DBHelper
using System; using System.Collections.Generic; using System.Text; using System.Configuration; using ...
- 上海有线通下载exe会302转发请求
起因: 做的软件用的clickonce,在公网的clickonce下载exe时一直报错,在vpn环境下没问题.错误提示如下: + HTTP redirect is not allowed for ap ...
- C++11特性(模板类 initializer_list)
[1]initializer_list模板类 C++primer 原文如下: 通读原文相关篇幅,分析解读内容如下: 提供initializer_list类的初衷,为了便于将有限个同一类型(或可转换为同 ...
- Java 邮件发送
<dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId&g ...
- [Solved]bcdedit.exe文件权限问题
最近在项目开发过程中,要使用到C:\Windows\system32\bcdedit.exe 但是在使用过程中,发现了一个问题.在命令行下面使用bcdedit.exe,如果是以管理员方式运行的命令行就 ...
- 关于onethink的迁移站点产生数据库错误
为了支持国产,本人使用了onethink建立了一个自己的站点( 模板世界:www.templatesy.com ),使用至今,虽然碰到了重重困难,还有很多bug,但总算也勉强建了起来. 在近期的一 ...
- openlayers 3 简书
1. 简书http://www.jianshu.com/p/6785e755fa0d 2. 文档 http://anzhihun.coding.me/ol3-primer/ch03/03-02.htm ...
- HQL查询——from子句
HQL查询--from子句 1.from是最基本的HQL语句,from关键字后紧跟持久化类的类名: from Person 表示从Person持久化类中选出全部的实例. 2.推荐为持久化类的每个实例起 ...
- Oracle客户端配置
1. 打开开发生产数据库系统,点击下载Oracle_12C_Client32,并且解压缩. 2. 找到文件下的setup.exe文件,并且执行. 3. 等待数秒,在如下界面中选择第二项,管理员, ...