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/ ...
随机推荐
- oracle中scn(系统改变号)
系统scn: select checkpoint_change# from v$database; 文件scn: select name ...
- CSS之float样式总结
从四大开始开始慢慢接触前端,大概半年多过去了,虽然做了一些东西,但感觉有些点始终不是很清晰.有时候为了赶进度,没有太多时间对某个点进行全面深入思考分析,只能从网上搜一搜,试一试,只要效果出来了,任务就 ...
- rc.local 增加自启动
编辑 /etc/rc.d/rc.local,将要执行的命令放里面. 然后给 rc.local 增加执行权限 chmod +x rc.local . 不过该方法正在被逐步淘汰,提示建议采用自定义服务的 ...
- eclipse中配置maven
http://jingyan.baidu.com/article/db55b609a994114ba20a2f56.html
- oracle函数,游标,视图使用总结0.000000000000000000001
oracle函数或者叫存储过程,在实际的开发过程中对于复杂的业务需求是非常有用的,非常有效率的也是非常好玩儿的一个技术点. 平常在开发过程中对于CRUD功能较多.一般SQL即可应付,大不了就是长一点而 ...
- POJ-1028 Web Navigation 和TOJ 1196. Web Navigation
Standard web browsers contain features to move backward and forward among the pages recently visited ...
- mySQL函数根据经纬度计算两点距离
DROP FUNCTION IF EXISTS func_calcDistance ; CREATE FUNCTION func_calcDistance( origLng ,), -- 目的地经度 ...
- jvisualvm参数配置
1.java 命令启动 nohup java -Dlocalcfg=true -Dcom.sun.management.jmxremote.port=9998 -Dcom.sun.management ...
- jmeter agent配置
Agent端配置 修改配置文件:JMETER_HOME/bin/jmeter.properties 中如下信息即可完成配置执行机远程启动端口(默认为 1099) server_port=1029 se ...
- PowerShell添加或修改注册表开机启动项脚本
代码如下: $name = Read-Host "请输入开机启动项的名字(随便起)" $value = Read-Host "请输入开机启动项的值" try{ ...