您的位置: 首页-> 电脑文摘-> 程序设计-> Delphi/Pascal-> 正文

CustomConnection部件的使用
作者佚名 来源InterNet 加入时间:2004-11-23
CustomConnection部件的使用

对于CustomConnection的使用,资料极少!今天我研究了一阵德文资料(先把德文转换为英
文)!
取得了一些进展!

CustomConnection是自定义德连接组件,通常用于获取非数据库的数据类型,比如内存数组
和二进制记录文件等。

在下面的例子中,我建立了一个IntArray数组,通过CustomConnection部件把数组数据传送
到RAVE报表中进行打印。

GetCols事件是用于字段的定义
procedure TForm1.RvCustomConnection1GetCols(
  Connection: TRvCustomConnection);
begin
    // data fields define
    // 各个字段的定义
    connection.WriteField('Name',dtInteger,30,'','');
end;

GetRow事件用于输出具体的每行数据
procedure TForm1.RvCustomConnection1GetRow(
  Connection: TRvCustomConnection);
Var
    i:Integer;
begin
    // actual data to the report hand over
    //输出每行数据
    Connection.WriteIntData('',intArray[CUrID]);
    INC(CUrID);
end;

Open事件用于确定要输出数据的总行数
procedure TForm1.RvCustomConnection1Open(Connection: TRvCustomConnection);
begin
    // number of data lines; There here header data only 1
    // 要输出数据的总行数
    Connection.DataRows:= 100;
end;


程序的源代码

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RpCon, RpBase, RpSystem, RpDefine, RpRave;

type
  TForm1 = class(TForm)
    RvProject1: TRvProject;
    RvSystem1: TRvSystem;
    RvCustomConnection1: TRvCustomConnection;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure RvCustomConnection1Open(Connection: TRvCustomConnection);
    procedure RvCustomConnection1GetRow(Connection: TRvCustomConnection);
    procedure RvCustomConnection1GetCols(Connection: TRvCustomConnection);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1:TForm1;
  CUrID:Integer;
  IntArray: Array[1..100] of integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
    i : integer;
begin
    For i := 1 to 100 do
        IntArray[i] := i;
    CUrID:=1;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    RvProject1.Execute;
end;

procedure TForm1.RvCustomConnection1Open(Connection: TRvCustomConnection);
begin
    // number of data lines; There here header data only 1
    // 要输出数据的总行数
    Connection.DataRows:= 100;
end;

procedure TForm1.RvCustomConnection1GetRow(
  Connection: TRvCustomConnection);
Var
    i:Integer;
begin
    // actual data to the report hand over
    //输出每行数据
    Connection.WriteIntData('',intArray[CUrID]);
    INC(CUrID);
end;

procedure TForm1.RvCustomConnection1GetCols(
  Connection: TRvCustomConnection);
begin
    // data fields define
    // 各个字段的定义
    connection.WriteField('Name',dtInteger,30,'','');
end;

end.
 


[文章录入员:fightter]

相关文章 相关软件:
::PCBOOKCN'ADS::


::Delphi/Pascal::
C/C++/VC
C++Builder
Basic/VB类
Delphi/Pascal
Java编程
FORTRAN
其它
::阅读排行::
·Delphi与Excel的亲密接...
·Delphi实现串口通信的常用的...
·DELPHI下的多线程程序设计(...
·Delphi中初始化.Ini文件...
·Delphi中用于读写(I/O)...
·谈谈Delphi中的类和对象
·Delphi编译错误中文手册
·Delphi中关于TApplic...
·OPENGL图形程序设计
·SQL的基本操作