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

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

下一个组件是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慧正在 火热销售中!>>查看价格详情

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年6月16日
下一篇 2021年6月16日

相关推荐

发表回复

登录后才能评论