机房收费系统小结之如何添加报表?


  在做到机房收费系统的时候,看到了这样一个界面  

  

  这是怎么出来的呢,其实这是一个报表,大家可以尝试用这个报表制作软件来试试---Grid++Report



为了在 VB 程序项目中使用 Grid++Report,首先必须在 VB 程序中加入对 Grid++Report 的引用。具体过程如下:


★在“工具箱”面板中加入 Grid++Report 对应构件:。 
1、打开部件窗口
2、点击右边的“浏览”按钮,打开文件“gregn50.dll”(默认安装在“C:Grid++Report 5.0”目录)。 保持列表中勾选“Grid++Report Engine5.8 Type Library”。
3、再次点击右边的“浏览”按钮,打开文件“grdes50.dll”(默认安装在“C:Grid++Report 5.0”目录)。 保持列表中勾选“Grid++Report Designer5.8 Type Library”。


一起来看一下代码

Option Explicit

Dim WithEvents Report As grproLibCtl.GridppReport


Private Sub Command1_Click()
    '因为报表对象的 Print 方法名与 VB 内部定义有冲突,所以要用中括号括起来
    Report.[Print] (True)
End Sub

Private Sub Command2_Click()
    Report.PrintPreview (True)
End Sub

Private Sub Form_Load()
    '创建报表对象
    Set Report = New grproLibCtl.GridppReport

    '载入报表模板文件,必须保证 Grid++Report 的安装目录在‘C:Grid++Report 4.5’下,
    '关于动态设置报表路径与数据绑定参数请参考其它例子程序
    Report.LoadFromFile ("C:UsersAdministratorDesktopjin.grf")
     Report.DetailGrid.Recordset.ConnectionString = "filedsn=shoufei.dsn;uid=sa;pwd=123456;"
    '设置报表查询显示器控件的关联报表对象
    GRDisplayViewer1.Report = Report

    '启动报表运行
    GRDisplayViewer1.Start
End Sub



原文地址:https://www.cnblogs.com/jinfulin/p/3797735.html