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/ ...
随机推荐
- dd-wrt 定时重连 pppoe 更换ip地址
因为做代理,IP时常被封的原因,所以,需要每天定时重启路由器,重启路由器影响太大,所以重新拨号是一个更好的选择. 在dd-wrt里面,杀掉pppoe服务进程就可以了,这个进程会自动重新启动,然后就相当 ...
- ecplise常用快捷键
常用 Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加)Ctrl+Alt+↑ 复制当前行到上一行(复制增加)Alt+ ...
- Graphics平移缩放旋转(转载)+点睛
点睛:可以进行多次旋转和平移,也就是平移以后再平移,旋转以后再旋转,有时候一次达不到要求,如果你想一次调整完美的话很麻烦,所以最好多次,上代码 private void btnTranslate_Cl ...
- hadoop是什么
Hadoop一直是我想学习的技术,正巧最近项目组要做电子商城,我就开始研究Hadoop,虽然最后鉴定Hadoop不适用我们的项目,但是我会继续研究下去,技多不压身. <Hadoop基础教程> ...
- MVC简单分层思想(连接数据库)
图片内容是所有的包名,文件名. 1.创建(M)模型 package oa.bean; public class User { private String userName; private Stri ...
- Candies-POJ3159差分约束
Time Limit: 1500MS Memory Limit: 131072K Description During the kindergarten days, flymouse was the ...
- react-native 调用 TouchableOpacity (触摸透明) 时报了一个警告
`useNativeDriver` is not supported because the native animated module is missing. Falling back to JS ...
- 年终汇报、总结、述职:教你做一场B格满满的技术大会演讲
什么样的演讲和呈现最受听众欢迎,内容干货?逻辑清晰?长相帅气? 偶尔被邀作为speaker参加一些圈内的技术大会进行演讲.这里我分享下自己的经验,如何做一场B格满满的技术大会演讲,希望给做汇报.总结. ...
- Word 宏命令大全
1. 为宏命令指定快捷键.在WORD中,操作可以通过菜单项或工具栏按钮实现,如果功能项有对应的快捷键的话,利用快捷键可以快速实现我们需要的功能.如最常见的CTRL+O.CTRL+A等等.WOR ...
- ubuntu安装(owncloud-docker安装)
1.源下载地址:http://mirrors.aliyun.com/ubuntu-releases/ ubuntu-16.04-server-amd64.iso 2.在虚拟机上安装完后 (1)查看IP ...