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 工具栏的更多相关文章

  1. ActiveReports中如何在后台导出运行时绑定数据源报表

    ActiveReports支持运行时绑定数据源功能,这种绑定数据源方法使用较为普及,然而很多系统中都需要在后台导出报表文件,所以用户就很困惑,ActiveReports中如何在后台导出运行时绑定数据源 ...

  2. Access 2003 中自定义菜单栏

    在Access中如何用自定义的菜单代替Access自带的菜单,现在做一个简单的介绍: 1.打开您做的Access数据库: 2.单击工具栏,选择“自定义…”: 3.在“自定义”窗口,单击“工具栏”选项卡 ...

  3. Html中自定义鼠标的形状

    Html中自定义鼠标的形状 <html> <head> <title>自定义的鼠标形状</title> <meta http-equiv=&quo ...

  4. 教你一招:在PowerPoint中自定义可输入文本的占位符

    日常生活中,当我们设计多媒体课件时,默认的版式其实已经够用了.但是,很多时候,我们需要更加个性一点,所以,我们需要自定义很多东西.本文介绍在PowerPoint中自定义可输入文本的占位符. 一.占位符 ...

  5. ActiveReports中如何控制页面的记录数

    在 ActiveReports 中,可以固定报表每页显示的行数,当每页的数据不足固定的行数时,自动通过填补空白行来实现,当然这两种功能仅限于区域报表和页面报表中. 区域报表 在区域报表中,有很多方法来 ...

  6. android代码优化----ListView中自定义adapter的封装(ListView的模板写法)

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...

  7. 在Eclipse中自定义类似syso的快捷代码模板

    sysout/syso syserr/ syse 点击菜单栏的“Window”->“Preferences”,打开“Preferences”对话框.在Preferences”对话框中点击“Jav ...

  8. 在.net桌面程序中自定义鼠标光标

    有的时候,一个自定义的鼠标光标能给你的程序增色不少.本文这里介绍一下如何在.net桌面程序中自定义鼠标光标.由于.net的桌面程序分为WinForm和WPF两种,这里分别介绍一下. WinForm程序 ...

  9. .net中自定义过滤器对Response内容进行处理

    原文:http://www.cnblogs.com/zgqys1980/archive/2008/09/02/1281895.html 代码DEMO:http://files.cnblogs.com/ ...

随机推荐

  1. Linux C 学习

    int main() { int64_t test = ; printf("%lld\n",test); float f_test = 100.2123; printf(" ...

  2. MVC简单分层思想(连接数据库)

    图片内容是所有的包名,文件名. 1.创建(M)模型 package oa.bean; public class User { private String userName; private Stri ...

  3. p12(PKCS12)和jks互相转换

    p12 -> jks keytool -importkeystore -srckeystore keystore.p12 -srcstoretype PKCS12 -deststoretype ...

  4. SAML 2.0 setup steps, 效果图

    Steps of setting up SAML SSO. 效果图 # Registry a Identity Provider services in:(Might need purchase) I ...

  5. c++多线程の死锁与防止死锁

    如果有两把锁 lock1(mutex_gard 方式)和lock: 两者的调用顺序不同,会出现相互等待的情况,从而造成死锁: 为了避免死锁,我们可以: 1.每个线程中锁的调用顺序都相同: 2.使用st ...

  6. DbnBase64加密处理

    package com.dbn.utils; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; impo ...

  7. VM出现该虚拟机正在使用中的提示,让获取所有权限解决办法

    今天打开虚拟机正要学习,结果说是虚拟机似乎正在使用中,让我重新获取权限.解决办法:打开提示的配置文件的位置,将一个以.lck结尾的文件夹删除或者保存为另外的文件名称,再打开虚拟机就OK了.

  8. 新接触PHP课程,给自己定制的目标

    PHP课程初接触,对自己的计划和展望恢复 从今天开始了为期四个半月的关于PHP课程的学习.从零开始接触一门新的技术知识,而且还是在短短四个月内就要掌握牢固,其实确确实实感觉不易.可是世间再没有路,不还 ...

  9. Asp.NET Visible属性与HTML display:none

    作为Asp.NET 程序猿,我们经常会遇到客户端HTML 元素与 WebPage Server端控件互操作的情景.如果没有很好的掌握两种技术的细节就很容易发生一些“莫名其妙的错误”. 我最近犯的一个错 ...

  10. EasyUI-validatebox 自定义validType验证

    根据项目要求,对于一些信息的验证也越来越特殊,当你发现EasyUI-validatebox提供的常用的validType验证类型已经满足不了你时,你可以选择自己自定义新的validType来完成信息验 ...