• ActiveReports中自定义Winforms的Viewer 工具栏


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

    预览效果:

    Shows a run-time view of the custom print button showing the tooltip text.

    核心代码:

    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
  • 相关阅读:
    application.properties /application.yml官网查看配置;springboot application.properties 官网查看,info yml 查看;springboot.yml查看info;springboot.yml查看Actuator监控中心info
    Clion 教程书写Hello World,C语言开发;Clion 的C语言开发
    Host is not allowed to connect to this MySQL server---------------->windows10
    @RequestBody jackson解析复杂的传入值的一个坑;jackson解析迭代数组;jackson多重数组;jakson数组
    windows10 搭建Dubbo
    无DNS解析环境下部署Vcenter6.7
    常用联想网络连接
    Linux 不重启扫描存储磁盘
    WWN,WWNN,WWPN三者的区别
    HDFS、Ceph、GFS、GPFS、Swift 等分布式存储技术的特点和适用场景
  • 原文地址:https://www.cnblogs.com/lenkaguo/p/5949516.html
Copyright © 2020-2023  润新知