彩票走势图

FastReport VCL报表开发人员手册:创建表组件

翻译|使用教程|编辑:杨鹏连|2021-07-19 09:35:47.327|阅读 180 次

概述:TfrxIBXTable继承自TfrxCustomDataSet标准类。所有基本功能(操作字段列表、主从、基本属性)都已经在基本类中实现。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

FastReport VCL是用于 Delphi、C++ Builder、RAD Studio 和 Lazarus 的报告和文档创建 VCL 库。它提供了可视化模板设计器,可以访问 30 多种格式,并可以部署到云、网站、电子邮件和打印中。

立即点击下载FastReport VCL v6.9最新版

下一个组件是TfrxIBXTable. 它继承自TfrxCustomDataSet标准类。所有基本功能(操作字段列表、主从、基本属性)都已经在基本类中实现。我们只需要定义特定于给定组件的属性。

  TfrxIBXTable = class(TfrxCustomTable)
  private
    FDatabase: TfrxIBXDatabase;
    FTable: TIBTable;
    procedure SetDatabase(const Value: TfrxIBXDatabase);
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    procedure SetMaster(const Value: TDataSource); override;
    procedure SetMasterFields(const Value: String); override;
    procedure SetIndexFieldNames(const Value: String); override;
    procedure SetIndexName(const Value: String); override;
    procedure SetTableName(const Value: String); override;
    function GetIndexFieldNames: String; override;
    function GetIndexName: String; override;
    function GetTableName: String; override;
  public
    constructor Create(AOwner: TComponent); override;
    constructor DesignCreate(AOwner: TComponent; Flags: Word); override;
    class function GetDescription: String; override;
    procedure BeforeStartReport; override;
    property Table: TIBTable read FTable;
  published
    property Database: TfrxIBXDatabase read FDatabase write SetDatabase;
  end;

constructor TfrxIBXTable.Create(AOwner: TComponent);
begin
  { create component – table }
  FTable := TIBTable.Create(nil);
  { assign link to  DataSet property from  basic class – do not forget this string! }
  DataSet := FTable;
  { assign link to connection to DB by default }
  SetDatabase(nil);
  { after that basic constructor may be called in}
  inherited;
end;

{ this constructor is called at moment of adding components to report. It connects table to TfrxIBXDatabase component automatically, if it is already present. }
constructor TfrxIBXTable.DesignCreate(AOwner: TComponent; Flags: Word);
var
  i: Integer;
  l: TList;
begin
  inherited;
  l := Report.AllObjects;
  for i := 0 to l.Count - 1 do
    if TObject(l[i]) is TfrxIBXDatabase then
    begin
      SetDatabase(TfrxIBXDatabase(l[i]));
      break;
    end;
end;

class function TfrxIBXTable.GetDescription: String;
begin
  Result := 'IBX Table';
end;

{ trace TfrxIBXDatabase component deleting. We address this component in FDatabase property. Otherwise we can get error. }
procedure TfrxIBXTable.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited;
  if (Operation = opRemove) and (AComponent = FDatabase) then
    SetDatabase(nil);
end;

procedure TfrxIBXTable.SetDatabase(const Value: TfrxIBXDatabase);
begin
  {  Database property of TfrxIBXDatabase type, and not of TIBDatabase one! }
  FDatabase := Value;
  { if value <> nil, connect table to selected component }
  if Value <> nil then
    FTable.Database := Value.Database
  { otherwise, try to connect to DB by default, defined in TfrxIBXComponents component }
  else if IBXComponents <> nil then
    FTable.Database := IBXComponents.DefaultDatabase
  { if there were no TfrxIBXComponents for some reason, reset to nil }
  else
    FTable.Database := nil;
  { if connection was a success DBConnected flag should be put }
  DBConnected := FTable.Database <> nil;
end;

function TfrxIBXTable.GetIndexFieldNames: String;
begin
  Result := FTable.IndexFieldNames;
end;

function TfrxIBXTable.GetIndexName: String;
begin
  Result := FTable.IndexName;
end;

function TfrxIBXTable.GetTableName: String;
begin
  Result := FTable.TableName;
end;

procedure TfrxIBXTable.SetIndexFieldNames(const Value: String);
begin
  FTable.IndexFieldNames := Value;
end;

procedure TfrxIBXTable.SetIndexName(const Value: String);
begin
  FTable.IndexName := Value;
end;

procedure TfrxIBXTable.SetTableName(const Value: String);
begin
  FTable.TableName := Value;
end;

procedure TfrxIBXTable.SetMaster(const Value: TDataSource);
begin
  FTable.MasterSource := Value;
end;

procedure TfrxIBXTable.SetMasterFields(const Value: String);
begin
  FTable.MasterFields := Value;
  FTable.IndexFieldNames := Value;
end;

{ we need to implement this method in some cases }
procedure TfrxIBXTable.BeforeStartReport;
begin
  SetDatabase(FDatabase);
end;

如果您对 FastReport 感兴趣,欢迎加入 FastReport QQ 交流群:702295239

还想要更多吗?您可以点击阅读【FastReport报表2021最新资源盘点】查找需要的教程资源。上是FastReport .NET慧正在网火热销售中!>>查看价格详情


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP